Update Update sketchDistanceSerial.ino
This commit is contained in:
parent
48fd3fd3ef
commit
2ccde493d6
|
@ -21,13 +21,13 @@ void loop() {
|
||||||
int ping(int TriggerPin, int EchoPin) {
|
int ping(int TriggerPin, int EchoPin) {
|
||||||
long duration, distanceCm;
|
long duration, distanceCm;
|
||||||
|
|
||||||
digitalWrite(TriggerPin, LOW); //Pause de 4 µs
|
digitalWrite(TriggerPin, LOW); //Démarrage de la séquence de 4 µs
|
||||||
delayMicroseconds(4);
|
delayMicroseconds(4);
|
||||||
digitalWrite(TriggerPin, HIGH); //Génération de 10 µs
|
digitalWrite(TriggerPin, HIGH); // Impulsion de déclenchement 10 µs
|
||||||
delayMicroseconds(10);
|
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
|
distanceCm = duration * 10 / 292/ 2; // Vitesse du son converti en cm
|
||||||
return distanceCm;
|
return distanceCm;
|
||||||
|
|
Loading…
Reference in New Issue