Abstract:The robot competition has become complex in track increasingly, from a single straight line and turning track in the past increased to difficulties as uphill and downhill, and so on. Because of the complexity of the robot race track, the method of controlling the movements of robot was put forward based on distance detection so as to ensure the robot moving on the variety track smoothly and quickly. The serial port position control and optical encoder were adopted to detect distance together. By establishing the mathematical model of the DC servo motor, PID was used to rectify movement gesture of robot. The robot speed was reckoned in detail on different path that provided important parameters for robot motion control. The results show that with using of this method the robot can march on complex circuit stably, reliably and rapidly by the test in the experiment ground.