Robotics Training LESSON 16: Using the HC-SR04 Ultrasonic Sensor for Echolocation

In this lesson we explain the concept of echolocation, and how the HC-SR04 ultrasonic sensor can be used to measure the time it takes a ping to go out, bounce off a target and come back. From this ping travel time, it is possible to  precisely calculate the distance to the target. For your convenience, the code we developed is included below.