This article is included in the ISTEM 2023 Series
- Review – Arduino Libraries Information Page
- In the Arduino IDE Library Manager, enter HC-SR04 into the search box.
- Find and Install the HC-SR04 library by Dirk Sarodnick.
- Open the HC-SR04 Simple example code.
- Modify the code so the triggerPin is set to 11.
- Check and Upload the code to the Arduino Nano.
- Open the Serial Monitor.
- Notice that the distance varies as you move your hand closer and away from the sensor.
Code Challenge!: My ruler is in inches, modify the code to display inches instead of centimeters.
- Verify operation using the Serial Monitor.
