Search wiring.org.co:

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Name |

### pulseIn()

Examples |
    int inpin = 8;
    int val = 0;

    void setup() {
      pinMode(inpin, INPUT);
      Serial.begin(9600);
    }

    void loop() {
      val = pulseIn(inpin, HIGH);
      Serial.println(val);
      delay(100);
    }
Description | The pulseIn() method returns the length in microseconds on a digital input pin for a short period of time from 10 milliseconds to 3 minutes. It can be used to read sensors that return a pulse train like some accelerometers or rangers. The user can specify the counting on HIGH or LOW transitions. The pulseIn command stops all activity while executing. A timeout of 1 second (1000000 microseconds) prevents the command to wait forever. A specific timeout in microseconds can also be specified.
Syntax |
    pulseIn(pin,transition)
    pulseIn(pin,transition,timeout)
Parameters |

pin | int: the pin used for reading the pulse
transition | HIGH or LOW
timeout | int: a timeout value in microseconds

Returns | int
Usage | Application

Updated on July 07, 2011 11:08:49pm PDT