uint32_t pulseIn( uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout = 1000000L );
uint32_t pulseIn( uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout = 1000000L );
Duration of acquiring voltage (HIGH or LOW) of a pin. The accuracy is us; range is approx. 10us to 3 mins.
|
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.) |
#define BUTTON 13 unsigned long duration; void setup() { pinMode(BUTTON, INPUT); } void loop() { duration = pulseIn(BUTTON, HIGH); }
wiring_pulse.h