The sensor has a transmitter and receiver. The transmitter sends a short sound burst. If an object is in front of it, the sound bounces back as an echo.
The controller measures the travel time. Since sound speed is known, the distance can be calculated from the echo time.
