Show minor edits - Show changes to markup
pulseIn(pin, value)
pulseIn(pin, value) \\
pulseIn(pin, value) pulseIn(pin, value, timeout)
the length of the pulse (in microseconds) or 0 if no pulse started before the timeout
the length of the pulse (in microseconds) or 0 if no pulse started before the timeout (unsigned long)
Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds.
The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length. Note that this function will not return until a pulse is detected.
Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out.
The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length.
timeout (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long)
the length of the pulse (in microseconds)
the length of the pulse (in microseconds) or 0 if no pulse started before the timeout
The timing of this function has been determined empirically and will probably show errors in longer pulses.Works on pulses from 10 microseconds to 3 minutes in length. Note that this function does not have a timeout built into it, so can appear to lock the Arduino if it misses the pulse.
The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length. Note that this function will not return until a pulse is detected.
Works on pulses from 10 microseconds to 3 minutes in length.
The timing of this function has been determined empirically and will probably show errors in longer pulses.Works on pulses from 10 microseconds to 3 minutes in length. Note that this function does not have a timeout built into it, so can appear to lock the Arduino if it misses the pulse.
Works on pulses from 10 microseconds to 3 minutes in length.
Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds.
pin: the number of the pin on which you want to read the pulse. (int)
value: type type of pulse to read: either HIGH or LOW. (int)
the length of the pulse (in microseconds)
int pin = 7;
unsigned long duration;
void setup()
{
pinMode(pin, INPUT);
}
void loop()
{
duration = pulseIn(pin, HIGH);
}