Update Update sketchDistanceSerial.ino

This commit is contained in:
Cédric Abonnel 2022-05-15 18:31:34 +00:00
parent 48fd3fd3ef
commit 2ccde493d6
1 changed files with 4 additions and 4 deletions

View File

@ -21,13 +21,13 @@ void loop() {
int ping(int TriggerPin, int EchoPin) {
long duration, distanceCm;
digitalWrite(TriggerPin, LOW); //Pause de 4 µs
digitalWrite(TriggerPin, LOW); //Démarrage de la séquence de 4 µs
delayMicroseconds(4);
digitalWrite(TriggerPin, HIGH); //Génération de 10 µs
digitalWrite(TriggerPin, HIGH); // Impulsion de déclenchement 10 µs
delayMicroseconds(10);
digitalWrite(TriggerPin, LOW); //Pause
digitalWrite(TriggerPin, LOW); // Arrêt de l'impulsion
duration = pulseIn(EchoPin, HIGH); // lecture
duration = pulseIn(EchoPin, HIGH); // Émission du signal et lecture
distanceCm = duration * 10 / 292/ 2; // Vitesse du son converti en cm
return distanceCm;