Skip to content

Commit 6feeb88

Browse files
authored
Merge pull request #483 from per1234/improve-pulsein-example
Make the pulseIn/pulseInLong example actually do something
2 parents 727bf5b + 32e830a commit 6feeb88

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Language/Functions/Advanced IO/pulseIn.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ the length of the pulse (in microseconds) or 0 if no pulse started before the ti
5353
[float]
5454
=== Example Code
5555
// 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.
5757

5858
[source,arduino]
5959
----
@@ -62,12 +62,14 @@ unsigned long duration;
6262
6363
void setup()
6464
{
65+
Serial.begin(9600);
6566
pinMode(pin, INPUT);
6667
}
6768
6869
void loop()
6970
{
7071
duration = pulseIn(pin, HIGH);
72+
Serial.println(duration);
7173
}
7274
----
7375
[%hardbreaks]

Language/Functions/Advanced IO/pulseInLong.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,21 @@ the length of the pulse (in microseconds) or 0 if no pulse started before the ti
5555
[float]
5656
=== Example Code
5757
// 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.
5959

6060
[source,arduino]
6161
----
6262
int pin = 7;
6363
unsigned long duration;
6464
6565
void setup() {
66+
Serial.begin(9600);
6667
pinMode(pin, INPUT);
6768
}
6869
6970
void loop() {
7071
duration = pulseInLong(pin, HIGH);
72+
Serial.println(duration);
7173
}
7274
----
7375
[%hardbreaks]

0 commit comments

Comments
 (0)