You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Language/Functions/Advanced IO/pulseIn.adoc
+22-11
Original file line number
Diff line number
Diff line change
@@ -25,20 +25,20 @@ The timing of this function has been determined empirically and will probably sh
25
25
26
26
[float]
27
27
=== Syntax
28
-
`pulseIn(pin, value)`
29
-
28
+
`pulseIn(pin, value)` +
30
29
`pulseIn(pin, value, timeout)`
31
30
31
+
32
32
[float]
33
33
=== Parameters
34
-
`pin`: the number of the pin on which you want to read the pulse. (int)
34
+
`pin`: the number of the Arduino pin on which you want to read the pulse. Allowed data types: `int`. +
35
+
`value`: type of pulse to read: either link:../../../variables/constants/constants/[HIGH] or link:../../../variables/constants/constants/[LOW]. Allowed data types: `int`. +
36
+
`timeout` (optional): the number of microseconds to wait for the pulse to start; default is one second. Allowed data types: `unsigned long`.
35
37
36
-
`value`: type of pulse to read: either link:../../../variables/constants/constants/[HIGH] or link:../../../variables/constants/constants/[LOW]. (int)
37
38
38
-
`timeout` (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long)
39
39
[float]
40
40
=== Returns
41
-
the length of the pulse (in microseconds) or 0 if no pulse started before the timeout (unsigned long)
41
+
The length of the pulse (in microseconds) or 0 if no pulse started before the timeout. Data type: `unsigned long`.
42
42
43
43
--
44
44
// OVERVIEW SECTION ENDS
@@ -53,24 +53,35 @@ the length of the pulse (in microseconds) or 0 if no pulse started before the ti
53
53
[float]
54
54
=== Example Code
55
55
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
56
-
The example calculated the time duration of a pulse on pin 7.
56
+
The example prints the time duration of a pulse on pin 7.
Copy file name to clipboardExpand all lines: Language/Functions/Advanced IO/pulseInLong.adoc
+20-7
Original file line number
Diff line number
Diff line change
@@ -27,20 +27,20 @@ The timing of this function has been determined empirically and will probably sh
27
27
28
28
[float]
29
29
=== Syntax
30
-
`pulseInLong(pin, value)`
31
-
30
+
`pulseInLong(pin, value)` +
32
31
`pulseInLong(pin, value, timeout)`
33
32
33
+
34
34
[float]
35
35
=== Parameters
36
-
`pin`: the number of the pin on which you want to read the pulse. (int)
36
+
`pin`: the number of the Arduino pin on which you want to read the pulse. Allowed data types: `int`. +
37
+
`value`: type of pulse to read: either link:../../../variables/constants/constants/[HIGH] or link:../../../variables/constants/constants/[LOW]. Allowed data types: `int`. +
38
+
`timeout` (optional): the number of microseconds to wait for the pulse to start; default is one second. Allowed data types: `unsigned long`.
37
39
38
-
`value`: type of pulse to read: either link:../../../variables/constants/constants/[HIGH] or link:../../../variables/constants/constants/[LOW]. (int)
39
40
40
-
`timeout` (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long)
41
41
[float]
42
42
=== Returns
43
-
the length of the pulse (in microseconds) or 0 if no pulse started before the timeout (unsigned long)
43
+
The length of the pulse (in microseconds) or 0 if no pulse started before the timeout. Data type: `unsigned long`.
44
44
45
45
--
46
46
// OVERVIEW SECTION ENDS
@@ -55,19 +55,21 @@ the length of the pulse (in microseconds) or 0 if no pulse started before the ti
55
55
[float]
56
56
=== Example Code
57
57
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
58
-
The example calculated the time duration of a pulse on pin 7.
58
+
The example prints the time duration of a pulse on pin 7.
59
59
60
60
[source,arduino]
61
61
----
62
62
int pin = 7;
63
63
unsigned long duration;
64
64
65
65
void setup() {
66
+
Serial.begin(9600);
66
67
pinMode(pin, INPUT);
67
68
}
68
69
69
70
void loop() {
70
71
duration = pulseInLong(pin, HIGH);
72
+
Serial.println(duration);
71
73
}
72
74
----
73
75
[%hardbreaks]
@@ -78,3 +80,14 @@ This function relies on micros() so cannot be used in link:../../interrupts/noin
0 commit comments