Ultrasonic sensor pan timing issue

Defer will only pause long enough for other processing around it to finish (in this case, there is nothing else to do…). Instead of the defer node, you will need a delay node between the time you set the servo angle & the time you take the reading. The servo can take around 0.2 seconds to reach its target destination.

If you find the servo jerking back & forth instead of moving to a new position, that is a different problem that needs another solution.