Update sketchDistanceSerial-Ultrasonic.ino
This commit is contained in:
parent
83e2d3adf3
commit
ec3e862530
|
@ -1,5 +1,8 @@
|
||||||
#include "Ultrasonic.h"
|
#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() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
@ -8,8 +11,9 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop () {
|
void loop () {
|
||||||
int dist = capteur.Ranging(CM);
|
distance = sensor.Ranging(CM);
|
||||||
Serial.print(dist);
|
Serial.print("Distance: ");
|
||||||
|
Serial.print(distance);
|
||||||
Serial.println(" cm");
|
Serial.println(" cm");
|
||||||
|
|
||||||
delay(100); // 100 ms
|
delay(100); // 100 ms
|
||||||
|
|
Loading…
Reference in New Issue