I had to design a circuit to open a door upon detecting a person. I used an ultrasonic sensor and a servo to accomplish this task. Ultrasonic sensors send out high-frequency sounds and count how long it takes for the echo to return. The distance to the object can then be found through simple unit conversions. A servo motor can track the position and know how far it has turned. The position of the shaft can be sensed by using a potentiometer, which is coupled with the motor shaft through gears. As the shaft turns, so does the potentiometer. The servo knows how far it has turned based on the resistance of the potentiometer. Here is a video showcasing the circuit.