From ec3e8625307edac939c8001cad83b4a05b8e4d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Abonnel?= Date: Sun, 15 May 2022 21:46:06 +0000 Subject: [PATCH] Update sketchDistanceSerial-Ultrasonic.ino --- arduino/sketchDistanceSerial-Ultrasonic.ino | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arduino/sketchDistanceSerial-Ultrasonic.ino b/arduino/sketchDistanceSerial-Ultrasonic.ino index a40adb7..df14921 100644 --- a/arduino/sketchDistanceSerial-Ultrasonic.ino +++ b/arduino/sketchDistanceSerial-Ultrasonic.ino @@ -1,6 +1,9 @@ #include "Ultrasonic.h" -Ultrasonic capteur(8,9); // Trig et Echo +Ultrasonic sensor(8,9); // Trig et Echo +// defines variables +int distance; // variable for the distance measurement + void setup() { Serial.begin(9600); pinMode (11, OUTPUT); @@ -8,8 +11,9 @@ void setup() { } void loop () { - int dist = capteur.Ranging(CM); - Serial.print(dist); + distance = sensor.Ranging(CM); + Serial.print("Distance: "); + Serial.print(distance); Serial.println(" cm"); delay(100); // 100 ms