From 32e830a3bdc777e507b670661035f071f9dfdf1a Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 23 Jan 2019 08:54:17 -0800 Subject: [PATCH] Make the pulseIn/pulseInLong example actually do something Previously, the example did nothing with the value of duration, which I think made it confusing to a beginner. --- Language/Functions/Advanced IO/pulseIn.adoc | 4 +++- Language/Functions/Advanced IO/pulseInLong.adoc | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Language/Functions/Advanced IO/pulseIn.adoc b/Language/Functions/Advanced IO/pulseIn.adoc index d1df8544f..893c67ce4 100644 --- a/Language/Functions/Advanced IO/pulseIn.adoc +++ b/Language/Functions/Advanced IO/pulseIn.adoc @@ -53,7 +53,7 @@ the length of the pulse (in microseconds) or 0 if no pulse started before the ti [float] === Example Code // Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ -The example calculated the time duration of a pulse on pin 7. +The example prints the time duration of a pulse on pin 7. [source,arduino] ---- @@ -62,12 +62,14 @@ unsigned long duration; void setup() { + Serial.begin(9600); pinMode(pin, INPUT); } void loop() { duration = pulseIn(pin, HIGH); + Serial.println(duration); } ---- [%hardbreaks] diff --git a/Language/Functions/Advanced IO/pulseInLong.adoc b/Language/Functions/Advanced IO/pulseInLong.adoc index 22940fd55..36f935f54 100644 --- a/Language/Functions/Advanced IO/pulseInLong.adoc +++ b/Language/Functions/Advanced IO/pulseInLong.adoc @@ -55,7 +55,7 @@ the length of the pulse (in microseconds) or 0 if no pulse started before the ti [float] === Example Code // Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄ -The example calculated the time duration of a pulse on pin 7. +The example prints the time duration of a pulse on pin 7. [source,arduino] ---- @@ -63,11 +63,13 @@ int pin = 7; unsigned long duration; void setup() { + Serial.begin(9600); pinMode(pin, INPUT); } void loop() { duration = pulseInLong(pin, HIGH); + Serial.println(duration); } ---- [%hardbreaks]