Using an ultrasonic sensor to control motor to move in the forward and reverse direction

What does your serial output show?