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

Hi @g4boi your program is working like this:

Read from a distance:
wait 1 second:
If the distance <= 10:
turn forward:
Rotate for a second:
Stop:
Read from a distance............
If the distance is greater than 10
turn back:
Rotate for a second:
Stop:
Read from a distance............
and it stays like this always...

RV mineirin