Update sketchDistanceSerial-Ultrasonic.ino

This commit is contained in:
Cédric Abonnel 2022-05-15 21:46:06 +00:00
parent 83e2d3adf3
commit ec3e862530
1 changed files with 7 additions and 3 deletions

View File

@ -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