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

Gonna be hard to debug your code without seeing your code. Please post your sketch.