Last active
March 23, 2022 14:03
-
-
Save cmoz/36ed19d292ff80f73bc1cfa4b5f26b71 to your computer and use it in GitHub Desktop.
Ultrasonic Sensor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <HCSR04.h> | |
UltraSonicDistanceSensor distanceSensor(13, 12); // Initialize sensor that uses digital pins 13 and 12. | |
void setup () { | |
Serial.begin(9600); // We initialize serial connection so that we could print values from sensor. | |
} | |
void loop () { | |
// Every 500 miliseconds, do a measurement using the sensor and print the distance in centimeters. | |
Serial.println(distanceSensor.measureDistanceCm()); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment