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

3. Core code analysis
Car direction diagram
q w e
a--丨--d
z x c
McLumk_Wheel_Sports library function required to control the car movement:
xrotate_left(speed)
Parameter explanation: Control the car to rotate left
speed: [0,255], the larger the value, the faster the left rotation
Return value: None.
xxxxxxxxxxrotate_right(speed)
Parameter explanation: control the car to rotate right
speed: [0,255], the larger the value, the faster the right rotation
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 rotates left for 1 second, right for 1 second, and finally stops.