esp/arduino/sketchDistanceUltrasonicSer...

17 lines
278 B
Arduino
Raw Normal View History

2022-05-15 19:38:28 +02:00
#include "Ultrasonic.h"
2022-05-15 19:48:11 +02:00
Ultrasonic capteur(8,9); // Trig et Echo
2022-05-15 19:38:28 +02:00
void setup() {
Serial.begin(9600);
pinMode (11, OUTPUT);
pinMode (12, OUTPUT);
}
void loop () {
2022-05-15 19:48:11 +02:00
int dist = capteur.Ranging(CM);
2022-05-15 19:38:28 +02:00
Serial.print(dist);
Serial.println(" cm");
2022-05-15 19:48:11 +02:00
delay(100); // 100 ms
2022-05-15 19:38:28 +02:00
}