Welcome to Raspbot V2 repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
3.Car sideways movement
03.Car sideways movement
03.Car sideways movement1. Learning objectives2. Experimental preparation3. Core code analysis4. Experimental phenomenon
1. Learning objectives
Control the left and right translation of the car.
2. Experimental preparation
As shown in the figure below, the motor needs to be connected to the expansion board.

3. Core code analysis
Direction of the car
q w e
a--丨--d
z x c
McLumk_Wheel_Sports library function required to control the movement of the car:
xmove_right(speed)
Parameter explanation: Control the right translation of the car
speed: [0,255], the larger the value, the faster the right translation speed
Return value: None.
xxxxxxxxxxmove_left(speed)
Parameter explanation: Control the car to move left
speed: [0,255], the larger the value, the faster the left translation
Return value: None.
Source code path: project_demo/04.Car_motion_control
Library path: /home/pi/project_demo/lib
4. Experimental phenomenon
Turn on the robot, open the computer browser to enter the Jupyter lab editor
Enter the source code path and double-click the code to be run

Restart the kernel and clear all outputs

Click the first code block, then click the run button to start running one by one

After the program runs, as the code blocks run, we can see that the car moves left for 1 second, right for 1 second, and finally stops.