Skip to content

Commit 47fef77

Browse files
committed
Explain difference between pulseIn() and pulseInLong()
Likely the question "What's the difference between this and pulseIn()" will be the first thing a user will want to know when visiting this page. Although this information was somewhat alluded to at the end of the description, it's much better for it to be at the start of the text. Reference: arduino/Arduino#2495 (comment)
1 parent 971576d commit 47fef77

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Language/Functions/Advanced IO/pulseInLong.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ subCategories: [ "Advanced I/O" ]
1717

1818
[float]
1919
=== Description
20+
`pulseInLong()` is an alternative to link:../pulsein[pulseIn()] which is better at handling long pulse and interrupt affected scenarios.
21+
2022
Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, `pulseInLong()` 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 or 0 if no complete pulse was received within the timeout.
2123

2224
The timing of this function has been determined empirically and will probably show errors in shorter pulses. Works on pulses from 10 microseconds to 3 minutes in length. Please also note that if the pin is already high when the function is called, it will wait for the pin to go LOW and then HIGH before it starts counting. This routine can be used only if interrupts are activated. Furthermore the highest resolution is obtained with large intervals.

0 commit comments

Comments
 (0)