Welcome to Raspbot repository
5.2 Drive motor
1. Learning target
In this course, we will learn how to drive motor of car.
2. Principle
For the Raspbot car, we use 4 TT DC gear motors. They are driven by the AT8236 chip. The driver chip is not directly connected to the Raspberry Pi pins.
Raspberry Pi communicates with STM8 MUC through IIC, and then STM8 MCU drives AT823612 chip to drive the motor.
3. Coding method
In this course, we use BOARD coding method.
STM8 is connected to SDA.1, SCL.1 on the Raspberry Pi board.
The pin comparison table of Raspberry Pi as shown below.

We have provided a library text dedicated to driving motors and servos --YB_Pcb_Car.py.
It is located in the same directory as the motor driver.
4. About code
Path: /home/pi/Yahboom_project/Raspbot/2.Hardware Control course/2.Drive motor
1) Import time and YB_Pcb_Car library
2) Control the car advance with a speed of 150 for two seconds (speed range: 0~255).
3) 3) Control the car back with a speed of 150 for two seconds (speed range: 0~255).
.......
4) Car stop
5) After using, we need to release the car object, otherwise, when the next program needs to use the object, it will be unusable due to it is occupied.
5. Running code
Click the button shown in the figure below to run the program on the Jupyter Lab interface
6. Experimental phenomena
Car will complete some actions.