Motor
Run program
Open the terminal of Raspberry Pi. Enter the following commands to test the motor.
1. Use the cd command to enter the directory where test.py is located.
cd ~/Freenove_4WD_Smart_Car_Kit_for_Raspberry_Pi/Code/Server
2. Execute test.py command:
sudo python test.py Motor
Result:
The car moves forward for 1 seconds, then moves back for 1 seconds, then turns left for 1 seconds, turns right
for 1 seconds, then stops. You can press "Ctrl + C" to end the program ahead of time. If the car doesn’t work
normally, please check if both switches are pressed.
If the direction is reversed, it moves back then move forward, please follow steps below.
1. Find Motor.py in the following path in your Raspberry Pi:
Freenove_4WD_Smart_Car_Kit_for_Raspberry_Pi/Code/Server/Motor.py
Open Motor.py and add a “–“ before duty1,2,3,4 like below.
def setMotorModel(self,duty1,duty2,duty3,duty4):
duty1,duty2,duty3,duty4=self.duty_range(duty1,duty2,duty3,duty4)
self.left_Upper_Wheel(-duty1)
self.left_Lower_Wheel(-duty2)
self.right_Upper_Wheel(-duty3)
self.right_Lower_Wheel(-duty4)