you use a while loop then put a bumper, and setting while (1)
you set bumper (bumper) int
you set if-then (bumper == 1)
you set the controlls on if
you set then (as the atonomous mode)
when the bumper hits the wall the robot will automatically go into atonamous mode, then after the motor programming, it will automatically go out of atonomous mode;)
Note: atonomous mode is automatic!!