ultrasonic (sonar) sensor
An ultrasonic sensor measures distance using sound: it chirps out a very high-pitched click — too high for human ears — and listens for the echo bouncing back off whatever is in front of it. Because sound travels through air at a steady, known speed, timing how long the echo takes to return reveals how far away the object is. It is much like how a bat finds its way in the dark, and how a parking sensor beeps faster as your bumper nears a wall.
Inside, a small element vibrates to send the pulse, then goes quiet and acts as a microphone to catch the returning echo. The longer the wait, the farther the object. Because the sound spreads out in a wide cone rather than a thin beam, the sensor can tell you roughly how far the nearest thing is, but not its precise shape or exactly which direction within that cone it sits.
Its appeal is that it is cheap, simple, and rugged, which makes it a favorite for basic obstacle and proximity detection on small robots and cars. The trade-offs: it is far less precise than LiDAR, soft or angled surfaces can swallow or deflect the echo so the object goes unseen, and it is slower, since each reading must wait for sound to make the round trip.
A small floor-cleaning robot uses cheap ultrasonic sensors to sense a wall just ahead and slow down before a bump, even though it cannot tell whether it is approaching a chair leg or a doorframe.
Good enough to avoid a bump, even if it cannot tell exactly what is there.
Ultrasonic sensing uses sound echoes; LiDAR uses light echoes — same time-of-flight idea, but light is far faster and gives much sharper detail.