PulseIn()

From Microduino Wiki
Revision as of 03:24, 17 August 2016 by Fengfeng (talk) (Created page with "<pre style="color:green"> unsigned long pulseIn (uint8_t pin, uint8_t state, unsigned long timeout) </pre> Read the pulse<br> Read the pulse of the pins, which can be HIG...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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]