The most common ways to sense distance are to use ultrasound or light. The principle of both types is to fire off a pulse and then sense its reflected return, using either its timing or angle to detect a distance. We will focus on the types of sensors that measure the time for a response, otherwise known as the time of flight. The following diagram shows how reflection time is used in these sensors:
Reflections of a distance sensor