https://www.youtube.com/watch?v=sG-Vqhkcas0

Using an ultrasonic sensor to trigger a servo is a simple task that requires you to design a system that uses measurements from the ultrasonic sensor to prompt the servo. This works because the sensor detects objects in front of it using sound, and calculates that distance. That data is observed and when it the measurements from the sensor fall into a specified range, the servo is prompted to operate instructions.