Syntax
uint32_t pulseIn(
    uint32_t ulPin, 
    uint32_t ulState, 
    uint32_t ulTimeout = 1000000L
);
ContentsIndex
PreviousUpNext
pulseIn
Example
Syntax
uint32_t pulseIn(
    uint32_t ulPin, 
    uint32_t ulState, 
    uint32_t ulTimeout = 1000000L
);
Description

Duration of acquiring voltage (HIGH or LOW) of a pin. The accuracy is us; range is approx. 10us to 3 mins.

Parameters
Parameters 
Description 
uint32_t ulPin 
[IN] Pin number measured 
uint32_t ulState 
[IN] Voltage type measured (HIGH or LOW) 
uint32_t ulTimeout = 1000000L 
[IN] The longest time allowed by the function before the measurement starts; unit: us (If not set, default will be 1s.) 
Example
#define BUTTON   13
unsigned long duration;
void setup()
{
    pinMode(BUTTON, INPUT);
}
void loop()
{
    duration = pulseIn(BUTTON, HIGH);
}
File

wiring_pulse.h

Group