Welcome to RDK X5 Robot repository
7.Control the motor to rotate forward and reverse
Control the motor to rotate forward and reverse
Control the motor to rotate forward and reverse7.1. Experimental Objectives7.2. Experimental Preparation7.3, Program source code7.4, Experimental effect
7.1. Experimental Objectives
Control the forward and reverse rotation of the robot's motor, and control the motor's movement speed by controlling the motor's PWM duty cycle.
7.2. Experimental Preparation
The red box in the picture below is the motor MOTOR 1, MOTOR 2, MOTOR 3, MOTOR 4. The line sequence of the four motor interfaces is consistent. The motor interface has an anti-reverse connection function. Use the motor cable to connect to the motor.
The line sequence of the motor interface is shown in the figure below:

MOTOR 1 is connected to the left front motor of the car, MOTOR 2 is connected to the left rear motor of the car, MOTOR 3 is connected to the right front motor of the car, and MOTOR 4 is connected to the right rear motor of the car.

The robot motor cable interface has a white interface at one end and a black interface at the other end. The white interface is connected to the expansion board and the black interface is connected to the motor.

SunriseRobotLib library functions needed to control the motor: