Exercise: Read Ultrasonic Ranger¶
Measure distance using a time-based process. Use the serial port for debugging.
Some processes we measure in the world involve measuring time. A sonar ranger emits a pulse of sound and measures the time it takes to reflect from an object back to the source. The distance is not itself a temporal quantity, but the dynamic process maps that distance to a time interval.
Steps and observations¶
Wire the circuit on the breadboard using the HC-SR04 ultrasonic ranger. Note that this module has one digital trigger input and one digital echo output.
Load and run the ReadSonar sketch.
Within the Arduino IDE, open the serial monitor console and make sure it is set to 9600 baud.
Observe the numbers printed in the serial monitor as you place a hard object a short distance in front of the sensor. It may take some time to find an object and orientation which yields a reliable signal.
Estimate the precision of the measurement. Is the scaling correct? Is there an offset error?