Here we will talk about one of the most commonly used sensors in toy and large scale moving robotics.
These sensors are usually used so that a robot will not bump into something and are composed of two parts a sender/emitter and a receiver unit.
The emitter lets out an ultransonic sound that comes out of a piezzo microphone usually with a certain frequency and when it hits an object in front of it it bounces back to the sensor.
The reflection is called an echo and when the reciever receives this echo it calculates the amount of time that has passed since the first sound was sent out and the return of the echo sound.
There are different brands of ultrasonic sensors and some may be better than others.
The Maxbotic company sells ultrasonic sensors and has an excellent website with tutorials explaining the differences in the types of sensors sold in the marketplace. Here is a link to them. https://www.maxbotix.com/tutorials.htm