Welcome to Tiny:bit Robot Car repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
2.CarRun
Learning goal:
This lesson learns how to control car advance, back,left and right by Python programming.
Code:
1) Import the library needed for this lesson from microbit: display for dot matrix display, Image calls the built-in image, tinybit controls the car;
2) display.show(Image.ARROW_S):Display forward arrow on the micro:bit dot matrix.
3) tinybit.car_run(150):Make car advance with 150 speed, Range of speed: 0~255.
4) display.show(Image.ARROW_N):Display backward arrows on the micro:bit dot matrix;
5) tinybit.car_back(150): Make car back with 150 speed, Range of speed: 0~255.
6) tinybit.car_left(150): Make car turn left with 150 speed, left wheel stop, right wheel advance.
7) tinybit.car_right(150): Make car turn right with 150 speed, right wheel stop, left wheel advance.
8) tinybit.car_spinleft(150): Make car spin left with 150 speed, right wheel advance, left wheel stop.
9) tinybit.car_spinright(150): Make car spin right with 150 speed, left wheel advance, right wheel stop.
10) tinybit.car_stop(): Make car stop.
11) display.clear(): Clear dot matrix.
From the hardware interface manual, we can know that the tracking sensor is directly driven by the micro:bit IIC pin.
Position of motor as shown below:
Programming and downloading:
1.You should open the Mu software, and enter the code in the edit window, , as shown below.
Note! All English and symbols should be entered in English, and the last line must be a space.
2.You can click the “Check” button to check if our code has an error. If a line appears with a cursor or an underscore, the program indicating this line is wrong.
3.Click “REPL” button,check whether the tinybit library has been downloaded. If not, please refer to the [preparation before class]---> [Python programming]
4.Click the “Flash” button to download the program to micro:bit board.
If the program is wrong or the experimental phenomenon is wrong after downloading, please confirm whether you have downloaded the Buildingbit libraryhex file we provided to the micro: bit board.
For the specific method of adding library files, please refer to 【1.Preparation before class】---【Python programming】
Experimental phenomena:
After download is complete, open the power switch. The car will go forward for one second, and the micro:bit dot matrix will display a forward arrow --> the car will go backward for one second, the dot matrix will display a backward arrow ---> the car will turn left for one second, the dot matrix displays the left arrow ---> the car turn right for one second, the dot matrix displays the right arrow ---> the car will spin left for one second, the dot matrix displays the left arrow ---> the car will spin right for one second, the dot matrix displays the right arrow ---> the car will stops for one second, the dot matrix clear display. And keep looping like this status.