PulseIn()

From Microduino Wiki
Jump to: navigation, search
unsigned long pulseIn (uint8_t pin, uint8_t state, unsigned long timeout) 			

Read the pulse

Read the pulse of the pins, which can be HIGH or LOW. If it is HIGH, the function will start counting when the pin changes into high level, until it changes into low level. The function returns the time that the pulse lasts for, in ms. If it hasn’t gotten the time when timeout, it will return 0.

  • Parameters:

pin Numbers of pins

state Pulse state

timeout

  • Example

Demonstrate the statistics of the lasting time of the high level:

int pin = 7;
unsigned long duration;

void setup()
{
  pinMode(pin, INPUT);
}

void loop()
{
  duration = pulseIn(pin, HIGH);
}

[Return to Arduino Syntax Manual]