Code
Using a Library designed for these sensors will make our code short and simple. We include the library at the beginning of our code,
and then by using simple commands we can control the behavior of the sensor.
After wiring, please open the program in the code folder- Lesson 6 Ultrasonic Sensor Module and click UPLOAD to upload the program.
See Lesson 3 for details about program uploading if there are any errors.
Before you can run this, make sure that you have installed the < HC-SR04> library or re-install it, if necessary. Otherwise, your code
won't work.
For details about loading the library file, see Lesson 2.