Answer
The device sends out an ultrasonic wave. The device measures the time it takes for the wave to strike the opposite wall and return to the device as an echo. Then the distance is calculated using the speed of the wave through the air and the elapsed time.
Work Step by Step
The device sends out an ultrasonic wave. The device measures the time it takes for the wave to strike the opposite wall and return to the device as an echo. Then the distance is calculated using the speed of the wave through the air and the elapsed time.
The principle is similar to the way some bat species use echolocation. These bats produce ultrasonic waves and then listen for the echo.