KS4031
KS4031
KS4031
(Makecode)
Contents
1. Introduction .................................................................................................................. 4
2. Description .................................................................................................................... 6
3.Parameters ...................................................................................................................... 6
5.Preparations: ............................................................................................................... 12
1
5.1Background Information about Micro:bit ............................................... 12
( 2 )Layout ....................................................................................................... 13
( 3 ) Pinout ...................................................................................................... 14
7.2.Makecode: ..................................................................................................... 53
7.6.Install CoolTerm:.......................................................................................... 77
8.Projects ......................................................................................................................... 79
2
Project 5: Temperature Measurement ......................................................... 113
3
Project 20: Bluetooth Multi-purpose Smart Car ....................................... 348
1. Introduction
age group, and it will be a trend for everyone to be able to program thanks
to Arduino and Raspberry Pi. Maybe you haven't heard of them before. It
doesn't matter because with the help of this product and tutorial, you can
being a maker.
programming.
4
This Keyestudio 4WD Mecanum Robot Car is a smart DIY car specially
designed for micro:bit. The smart car kit consists of a car body with
extended functions, a PCB base plate with integrated motor drive sensors,
and acrylic boards. Therefore, you can easily assemble a cool Mecanum
wheel 4WD smart car by yourself, and then use Microsoft's online graphical
to control the car. In the process, you can not only experience the fun of
well.
For your convenience, source code has been provided in every project, as
well as code programming steps and code explanation in details. Hope you
5
2. Description
make direction lights for the car. This product uses two 18650 lithium
When installing and disassembling the battery, please pay attention to the
positive and negative poles of the battery, and be sure not to reverse the
3.Parameters
◆ Size: 120*120*120mm
6
Note: working voltage of micro:bit is 3.3V, driver shield integrates 3.3V/5V
4.Kit List
Quanti
# Picture Components
ty
3 4.5V Motor 4
4 4
23*15*5MM Fixing Board
7
5 Servo 1
6 Mecanum Wheels 4
Level Conversion
8
Micro:bit Main Board V2.0 for
KS4032 0
8
9 1
Keyestudio Driver Board
11 4
4265c Lego Part
12 4
43093 Lego Part
9
14 M3*6MM Round Head Screw 18
16 M3 Nickle-plated Nut 14
18 M2 Nickle-plated Nut 3
10
20 M3*8MM Round Head Screw 5
23 USB Cable 1
50mm
11
28 3*40mm Screwdriver 1
5.Preparations:
( 1 )What is Micro:bit?
with ARM, Barclays, element14, Microsoft and other institutions. The core
Though it is just the size of a credit card, the Micro:bit main board is
energy, and a buzzer and others. Thus, it also boasts multiple functions.
The buzzer built in the other side of the board makes playing all kinds of
sound possible without any external equipment. The golden fingers and
12
gears added provide a better fixing of crocodile clips. Moreover, this board
be entered if users long press the Reset & Power button on the back of it. It
is capable of reading the data of sensors, controlling servos and RGB lights
compatible with almost all PCs and mobile devices. It has no need to install
make some cool inventions like robots and musical instruments, basically
everything imaginable.
( 2 )Layout
13
For more information,please resort to following links :
https://tech.microbit.org/hardware/
https://microbit.org/new-microbit/
https://www.microbit.org/get-started/user-guide/overview/
https://microbit.org/get-started/user-guide/features-in-depth/
( 3 ) Pinout
14
The functions of pins:
P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,
GPIO
P13,P14,P15,P16,P19,P20
ADC/DAC P0,P1,P2,P3,P4,P10
IIC P19(SCL),P20(SDA)
SPI P13(SCK),P14(MISO),P15(MOSI)
PWM(used
P0,P1,P2,P3,P4,P10
frequently)
PWM(not
P5、P6、P7、P8、P9、P11、P12、P13、P14、P15、P16、P19、
frequently
P20
used)
15
P3(LED Col3),P4(LED Col1),P5(Button A),P6(LED Col4),
Occupied
P7(LED Col2),P10(LED Col5),P11(Button B)
https://tech.microbit.org/hardware/edgeconnector/
https://microbit.org/guide/hardware/pins/
b. Its IO port is very weak in driving since it can merely handle current less
Furthermore, you must figure out the current requirements of the devices
before you use them and it is generally recommended to use the board
c. It is recommended to power the main board via the USB interface or via
the battery of 3V. The IO port of this board is 3V, so it does not support
board is required.
16
d. When using pins(P3, P4, P6, P7 and P10)shared with the LED dot matrix,
blocking them from the matrix or the LEDs may display randomly and the
e. Pin 19 and 20 can not be used as IO ports though the Makecode shows
f. The battery port of 3V cannot be connected with battery more than 3.3V
for use.
to recognize the main board, you can install the diver too.
17
Just enter the link https://fs.keyestudio.com/KS4031-4032
file folder
This chapter will introduce the function and structure of keyestudio 4WD
lights, 4 WS2812 RGB lights. The wiring is not complicated and it has
hardware resources will enable you to master more knowledge and skills,
inventions.
This car can help you to better learn to use Micro:bit and obtain electronic
knowledge.
18
lights 4 decelerating DC motors, Mecanum wheels,
# 2 4 1 1 1 1 4 1
Note: the line tracking sensor, WS2812 RGB lights and infrared receiver
Pins:
P14 Servo
P8 4 个 WS2812RGB Lights
P9 Infrared Receiver
batteries. The battery holder of the car is compatible with any type of
19
charger to charge the 18650 lithium battery.
Part 1
Components
Needed
20
Installation
Diagram
Prototype
Part 2
21
Components
Needed
Installation
Diagram
22
Prototype
Part 3
23
Components
Needed
Installation
Diagram
24
Prototype
Adjust the
angle of the
servo to 90
degrees
according to
in project
8.15
25
Components
Needed
Installation
Diagram
(mind the
installation
direction)
26
Prototype
Part 5
Components
Needed
27
Installation
Diagram
Prototype
Part 6
28
Components
Needed
Installation
Diagram
29
Prototype
Part 7
Components
Needed
30
Installation
Diagram
(mind the
direction of
the motor)
Prototype
Part 8
31
Components
Needed
Installation
Diagram
(Pay
attention to
the
installation
direction of
the
mecanum
wheel)
32
Prototype
Part 9
Components
Needed
33
Installation
Diagram
Prototype
Part 10
34
Components
Needed
Installation
Diagram
35
Prototype
Start Wiring
The wiring of
the RGB
lights
36
The wiring of
the infrared
receiver
module
The wiring of
the motor
and colorful
lights
37
The wiring of
the
line-tracking
sensor
The wiring of
the
ultrasonic
sensor
38
The wiring of
the servo
The wiring of
the
M1 motor
39
The wiring of
the
M2 motor
The wiring of
the
M3 motor
40
The wiring of
the
M4 motor
The wiring of
the power
supply (the
5V is
connected to
the shield)
41
7.Get Started with Micro:bit
The following instructions are applied for Windows system but can also
This chapter describes how to write program and load the program to the
You are recommended to browse the official website of Micro:bit for more
https://microbit.org/guide/quick/
Step 1: connect the Micro: Bit main board with your computer
Firstly, link the Micro: Bit main board with your computer via the USB cable.
Note that if you are about to pair the board with your phone or tablet,
https:/microbit.org/get-started/user-guide/mobile/
42
Secondly, if the red LED on the back of the board is on, that means the
board via the USB cable, the yellow LED on it will flashes. For example, it
Then Micro: bit main board will appear on your computer as a driver
shown below.
43
Step 2: write programs
(If you are running Windows 10 system, it is also viable to edit on the APP
MakeCode for micro:bit , which is exactly like editing in the website. And
https://www.microsoft.com/zh-cn/p/makecode-for-micro-bit/9pjc7sv48lcx
?ocid=badgep&rtc=1&activetab=pivot:overviewtab )
44
45
Write a set of micro:bit code. You can drag some modules in the Blocks to
the editing area and then run your program in Simulator of MakeCode
‘heartbeat’ program .
46
47
Step 3: download code
download the program to your Micro: Bit main board is merely clicking the
If you are writing program through the website, following these steps:
compact program format that the Micro: Bit main board can read. Once
the hexadecimal file is downloaded, copy it to your board just like the
48
process that you copy the file to the USB driver. If you are running
MICROBIT(E:) ‘to copy the hex file to the Micro: Bit main board.
49
You can also directly drag the "hex" file onto the MICROBIT (E:) disk.
50
During the process of copying the downloaded hex file to the Micro: bit
main board, the yellow signal light on the back side of the board flashes.
When the copy is completed, the yellow signal light will stop flashing and
remain on.
After the program is uploaded to the Micro: bit main board, you could still
power it via the USB cable or change to via an external power. The 5 x 5 LED
51
dot matrix on the board displays the heartbeat pattern.
Caution:
When you programs each time, the driver of Micro: bit will automatically
eject and return and your hexadecimal files will disappear . And the board
can only have access to hexadecimal files (hex) and save no other files.
This chapter has described how to use the Micro:bit main board.
But except for the Makecode graphical programming introduced you can
52
to have a go.
7.2.Makecode:
53
Setting
按钮 销
When the power is plugged or reset,“on start”means that the code in the
block only executes once, while “forever”implies that the code runs
cyclically.
54
program written can be quickly downloaded to the Micro: Bit main board
by selecting ‘Download’.
You could refer to the following steps to connect and pair devices.
Device pairing:
55
Click“Next”;
56
Click another“Next”;
57
Then select the corresponding device and click“Connect”. If no devices
https://makecode.microbit.org/device/usb/webusb/troubleshoot
https://microbit.org/guide/firmware/ .
If the links are too troublesome for you , then you can also turn to our
58
in the folder we provided in the link:
https://fs.keyestudio.com/KS4031-4032
59
60
Download program:
will shift to .
61
7.4.Makecode extension library:
For your convenience, we have made a makecode extension library for this
62
Open Makecode to enter a certain project→click the gear-shaped icon(for
63
Input the link https://github.com/keyestudio2019/ks_IoT to search;
64
After the installation, you can find the extension files DHT11/DHT22 and
65
66
67
Note: the extension files added are only available for this project. Therefore,
when you create a new IoT_keyestudio project, you will need to add these
68
Click the “Explorer”on the left side:
69
You can find these added files in the list;
Click the dustbin icon beside the file to delete the corresponding file;
extension file.
70
7.4.Resources and test code
containing the information of the product from relevant tools to test codes,
below:
71
7.5.Input test code
We provide hexadecimal code files (project files) for each project. The file
contains all the contents of the project and can be imported directly, or you
can manually drag the code blocks to complete the program for each
Let's take the "Heatbeat" project as an example to show how to load the
code.
Makecode;
72
Click“Import File”;
73
Select“../Makecode Code/Project 1_ Heart beat/Project 1_ Heart beat.hex”
74
In addition to importing the test code file provided into the Makecode
compiler above, you can also drag the the test code file provided into the
code editing area of the Makecode compiler, as shown in the figure below:
75
Note: if your computer system is Windows7 or 8 instead of Windows 10,
the pairing cannot be done via Google Chrome. Therefore, digital signal or
analog signal of sensors and modules cannot be shown on the serial port
analog signal.So what can we do? You can use the CoolTerm software to
read the serial port data of the microbit. Next chapter is about how to
install CoolTerm.
76
7.6.Install CoolTerm:
https://freeware.the-meiers.org/
(2) Unzip file and open it. (also suitable for Mac and Linux system)
(1)
77
(3) Double-click (
. please make sure that the driver of Micro:bit is
78
Open up a new Terminal
8.Projects
(Note: project 8.1 to 8.12 will be conducted with the built-in sensors and
79
Project 1: Heartbeat
(1)Project Description
This project is easy to conduct with a micro:bit V2 main board, a Micro USB
cable and a computer. The micro:bit LED dot matrix will display a relatively
big heart-shaped pattern and then a smaller one. This alternative change
of this pattern is like heart beating. This experiment serves as a starter for
(2)Experimental Preparation:
80
(3)Test Code
Code/Project 1:Heartbeat
Go to“Basic”→“show icon”.
81
Click“ ”to select“ ”.
Complete Program:
82
(4)Test Results
Download code to micro:bit and keep USB cable connected. The LED dot
computer and then reconnect them and reopen Makecode to try again.
(1)Project Description
to locate these LEDs quickly, as the figure shown below, we can regarded
this matrix as a coordinate system and create two aces by marking those in
rows from 0 to 4 from top to bottom, and the ones in columns from 0 to 4
from the left to the right. Therefore, the LED sat in the second of the first
line is (1,0)and the LED positioned in the fifth of the fourth column is (3,4)
83
and others likewise.
(2)Experimental Preparation:
(3)Test Code
84
LED
B. Put it into the“on start”block, and click the drop-down triangle button
to select“true”.
*****************************************************************************
*****************************************************************************
85
B. Then move it below the “toggle x1 y0”block, and set to 500ms.
block.
*****************************************************************************
A. Enter“Led”→“plot x 0 y 0”
86
*****************************************************************************
87
block.
88
Click“JavaScript”to switch into corresponding JavaScript code:
Complete Program:
Delay in 500ms
89
(4)Test Results:
After uploading test code to micro:bit main board V2 and powering the
main board via the USB cable, the LED in (1,0) lights up for 0.5s and the one
90
(1)Project Description
Dot matrices are very commonplace in daily life. They have found wide
The LED dot matrix of Micro: Bit main board V2 contains 25 LEDs in a grid.
integrating its position value into the test code. Supported by the same
theory, we can turn on many LEDs at the same time to showcase patterns,
What’s more, we can also click”show icon“ to choose the pattern we like
to display. Last but not the least, we can design patterns by ourselves.
(2)Experimental Preparation:
(3)Test Code
Code 1:
91
The route to get test code(How to load?)
Matrix-1
*****************************************************************
0 y 0”for 8 times, respectively set to“x 2”y 0”,“x 2”y 1”,“x 2”y 2”,
“x 2”y 3”,“x 2”y 4”,“x 1”y 3”“x 0”y 2”,“x 3”y 3”,“x 4”y 2”.
92
Complete Program:
93
“on start”: command block only
language code:
Code 2:
94
The route to get test code(How to load?)
Matrix-2
*****************************************************************
95
Click“Basic”→“show leds”, then put it into“forever”block,tick blue boxes
*****************************************************************
block“show string“Hello!”block
96
*****************************************************************
West”.
97
(3) Click“Basic”to get block“clear screen”then remain it below the block
*****************************************************************
98
leave it below“clear screen”block.
Complete Program:
99
“on start”: command block only runs once to start
program.
matrix
dot matrix
dot matrix
Delay in 500ms
100
Select“JavaScript" and“Python”to switch into JavaScript and Python
language code:
(4)Test Results:
Upload code 1 and power the board , we will see the icon
101
Upload code 2 and plug micro:bit in power, Micro: bit starts showing
, , and patterns.
(1)Project Description
with a push button, the circuit is connected when pressing the button and
Micro: Bit main board boasts three push buttons, two are programmable
102
buttons(marked with A and B), and the one on the other side is a reset
and the LED dot matrix shows A,B and AB respectively. Let’s get started.
(2)Experimental Preparation:
(3)Test Code
Code 1:
103
Hex file KS4031(4032) folder/Makecode Project 4:
Buttons-1
A pressed”
*****************************************************************
“A”.
104
*****************************************************************
*****************************************************************
Complete Code:
105
Press button A on Micro: bit
main board
main board
time
language code:
Code 2:
106
The route to get test code(How to load?)
Buttons-2
“true” .
*************************************************************************
107
A. Click“Input”→“on button A pressed”.
*************************************************************************
******************************************************************************
108
B. Keep it into“forever”block
*****************************************************************************
0 into 25.
******************************************************************************
109
(7) A. Replicate code string once
Complete Program:
110
“on start”: command block runs once
to start program.
Change item by 5
Change item by -5
25 LEDs
111
(4)Test Results:
After uploading test code 1 to micro:bit main board V2 and powering the
main board via the USB cable, the 5*5 LED dot matrix shows A if button A is
After uploading test code 2 to micro:bit main board V2 and powering the
main board via the USB cable, when pressing the button A the LEDs turning
red increase by 5 while when pressing the button B the LEDs turning red
reduce.
112
(How to download? How to quick download?)
(1)Project Description
but uses the temperature sensor built into NFR52833 chip for temperature
temperature of the chip, and there maybe deviation from the ambient
temperature.
(2)Experimental Preparation:
113
Import Hex profile (How to import?)
(3)Test Code
Code 1:
Code/Project 5:Temperature
Measurement-1
114
*****************************************************************************
Move it into“forever”block
Go to“Input” →“temperature(℃)”
*****************************************************************************
write.....temperature(℃)”
115
Complete Program:
116
“on start”: command block runs once to start program.
Delay in 500ms
117
Download code 1 to micro:bit board and keep USB cable connected, then
tap button :
118
Through the test, the room temperature is 35 ℃ when touching the
Open CoolTerm, click Options to select SerialPort. Set COM port and
The serial monitor shows the current ambient temperature value, as shown
below:
119
120
121
122
Code 2:
123
Hex file KS4031(4032) folder/Makecode Project 5:Temperature
Code/Project 5:Temperature
Measurement-2
*****************************************************************
“true”box.
******************************************************************************
124
A. Change“=”into“≥”
*****************************************************************
“if ...then” and else blocks, then click the drop-down triangle button to
select“ ”.
125
Complete Program:
to start program.
runs cyclically.
126
(4)Test Results:
Upload the Code 1 and plug in power. And 5*5LED displays the ambient
Upload the code 2 plug in micro:bit via USB cable, when the ambient
appear.
(1)Project Description
addition to detecting the strength of the magnetic field, it can also be used
127
It uses FreescaleMAG3110 three-axis magnetometer. Its I2C interface
communicates with the outside, the range is ±1000µT, the maximum data
blocks.
In addition, the objects nearby may affect the accuracy of readings and
calibration.
(2)Experimental Preparation:
(3)Test Code
Code 1:
128
File Type Path File Name
Code/Project 6:
Geomagnetic Sensor-1
A. Click“Input”→“more”→“calibrate compass”
*****************************************************************
129
Complete Program:
to start program.
②Calibrate compass
heading
language code:
Code Description:
rotate the micro:bit to make LED dot matrix draw a square (25 LEDs are on),
130
(How to download? How to quick download?)
The calibration will be finished until you view the smile pattern
appear.
The serial monitor will show 0°, 90°, 180° and 270° when pressing A.
Code 2:
Make micro: bit board point to the north, south, east and west horizontally ,
131
File Type Path File Name
Code/Project 6:
Geomagnetic Sensor-2
This module can keep reading data to determine direction, so does point
132
For the above picture, the arrow pointing to the upper right when the value
ranges from 292.5 to 337.5. Because 0.5 can’t be input in the code, the
Link computer with micro:bit board by micro USB cable, and program in
MakeCode editor:
133
*****************************************************************
B. Input“x”in the blank box and click“OK”, and the variable “x” is
generated.
*****************************************************************
A. Place“and”into“true”block
set to “≥”;
“x<338”
134
*****************************************************************
A. Go to“Basic”→“show leds”
block, then
135
A. Duplicate for 6 times.
B. Separately leave them into the blank boxes behind “else if”.
136
“x≥158 and x<203 ”,“x≥203 and x<248 ”,“x≥248 and x<293 ”
respectively.
D. Then copy “show leds”for 7 times and keep them below the “else
“ ”, “ ”and “ ”.
*****************************************************************************
Complete Program:
137
“on start”: command block only
runs once to start program.
Calibrate compass
will be executed
pattern appears
138
When 158≤x<203, the next
language code:
139
140
(4)Test Results:
Upload code 2 and plug micro:bit into power. After calibration, tilt
micro:bit board, and the LED dot matrix displays the direction signs.
141
Project 7: Accelerometer
(1)Project Description
communication, the range can be set to ±2g, ±4g, and ±8g, and the
changes.
For this project, we will introduce the detection of several special postures
by the accelerometer.
(2)Experimental Preparation:
142
Import Hex profile (How to import?)
(3)Test Code
Code 1:
Code/Project 7:Accelerometer-1
B. Click“Basic”→“show number”
, place it into“on shake”block, then change
143
0 into 1.
change 1 into 2, 3, 4, 5, 6, 7, 8.
******************************************************************************
Complete Program:
144
Shake the Micro:bit board
The log is up
The screen is up
145
The screen is down
Number 5 is shown
Number 6 is displayed
Number7 is displayed
146
Code 2:
Code/Project 7:Accelerometer-2
147
Or you could edit code step by step in the editing area.
******************************************************************************
B. Leave it into“forever”block
**************************************************************************A.
Click“Input”→“acceleration(mg) x”;
*****************************************************************************
148
*****************************************************************************
149
Complete Program:
Download code 1 to micro:bit board, keep USB cable connected and click
150
(How to quick download?)
schematic diagram of the Micro: Bit main board V2, the accelerometer
coordinate of the Micro: Bit V2 motherboard are shown in the figure below:
151
The following interface shows the decomposition value of acceleration in X
152
If you're running Windows 7 or 8 instead of Windows 10, via Google
Chrome won't be able to match devices. You'll need to use the CoolTerm
You could open CoolTerm software, click Options, select SerialPort, set
COM port and put baud rate to 115200 (after testing, the baud rate of USB
153
SerialPort communication on Micro: Bit main board V2 is 115200), click OK,
and Connect. The CoolTerm serial monitor shows the data of X axis, Y axis
(4)Test Results:
After uploading the test code 1 to micro:bit main board V2 and powering
the board via the USB cable, if we shake the Micro: Bit main board V2. no
matter at any direction, the LED dot matrix displays the digit “1”.
154
When it is kept upright (make its logo above the LED dot matrix), the
number 2 shows.
When it is kept upside down( make its logo below the LED dot matrix) , it
shows as below.
When it is placed still on the desk, showing its front side, the number 4
appears.
When it is placed still on the desk, showing its back side, the number 5
exhibits.
When the board is tilted to the left , the LED dot matrix shows the number
155
6 as shown below.
When the board is tilted to the right , the LED dot matrix displays the
When the board is knocked to the floor, this process can be considered as
a free fall and the LED dot matrix shows the number 8. (please note that
this test is not recommended for it may damage the main board.)
Attention: if you’d like to try this function, you can also set the
156
Project 8: Light Detection
(1)Project Description
In this project, we focus on the light detection function of the Micro: Bit
main board V2. It is achieved by the LED dot matrix since the main board is
When the light irradiates the LED matrix, the voltage change will be
change.
(2)Experimental Preparation:
(3)Test Code
157
The route to get test code(How to load?)
***************************************************************************
B. Move it into“forever”
A. Click“Input”→“acceleration(mg) x”
intensity”.
158
***************************************************************************
***************************************************************************
Complete Program:
159
“on start”: command block runs once to start program.
= light level
Delay in 100ms
160
(4) Test Results:
Download code to micro:bit board don’t plug off USB cable and click
The intensity value is 0 when covering LED dot matrix. And the value varies
with the light intensity. When placing micro:bit under the sunlight, the
stronger the light is, the larger the intensity value is. As shown below:
161
Open“CoolTerm”, click“Options”to select “SerialPort”, and set
“COM” port and 115200 baud rate(the baud rate of USB serial
Then click“OK”and“Connect”.
162
Project 9: Speaker
163
(1)Project Description
The Micro: Bit main board V2 has an built-in speaker, which makes adding
sound to the programs easier. We can program the speaker to air all kinds
(2)Experimental Preparation:
(3)Test Code:
Tutorial/Makecode Code/Project
Code/Project 9:Speaker
164
Or you could edit code step by step in the editing area.
block;
******************************************************************************
into “forever”block;
block ;
165
“forever” block ;
******************************************************
166
Complete Program:
language code:
167
(4)Test Results:
After uploading the test code to micro:bit main board V2 and powering the
board via the USB cable, the speaker utters sound and the LED dot matrix
168
Project 10: Touch-sensitive Logo
(1)Project Description
logo, which can act as an input component and function like an extra
button.
electric field when pressed (or touched), just like your phone or tablet
(2)Experimental Preparation:
(3)Test Code
169
The route to get test code(How to load?)
Tutorial/Makecode Code/Project
10:Touch-sensitive Logo
→click“OK”
170
touched”block;
touched”block;
pressed”block;
0”block;
171
( 7 )Enter“Input”module→ “more” → find and drag “running time(ms)”
side of “0-0”;
released”block;
172
side of “ 0-0 ” and change the “ 0 ” on the right side to ” 1000 ” ;
Complete Program:
173
Select“JavaScript" and“Python”to switch into JavaScript and Python
language code:
(4)Test Results:
After uploading the test code to micro:bit main board V2 and powering the
board via the USB cable, the LED dot matrix exhibits the heart pattern
174
when the logo is released.
(1)Project Description
The Micro: Bit main board V2 is built with a microphone which can test the
indicator turns on. Since it can measure the intensity of sound, you can
make a noise scale or disco lighting changing with music. The microphone
proximity with holes that lets sound pass.When the board detects sound,
(2)Experimental Preparation:
175
Import Hex profile (How to import?)
(3)Test Code
Code 1
11:Microphone-1
sound”block ;
176
( 3 )Copy once;
Complete Program:
language code:
177
(4)Test Results 1:
After uploading test code to micro:bit main board V2 and powering the
board via the USB cable, the LED dot matrix displays pattern “ ”when
Code 2:
178
File Type Path File Name
11:Microphone-2
start”block ;
block ;
179
Enter“Basic”module to find and drag“show number”into “then” ;
Establish variable“soundLevel”;
“else”;
180
Enter“Led”module to find and drag“plot bar graph of 0 up to 0”
into “else”;
“of”;
181
Enter“Variables”module to find and drag“set maxSound to 0”into the
second “then” ;
182
Complete Program:
language code:
183
184
(5)Test Results 2:
Upload test code to micro:bit main board V2, power the board via the USB
When the sound is louder around, the sound value shows in the serial port
185
What’s more, when pressing the button A, the LED dot matrix displays the
value of the biggest volume( please note that the biggest volume can be
reset via the Reset button on the other side of the board ) while when
clapping, the LED dot matrix shows the pattern of the sound.
186
Project 12: Bluetooth Wireless Communication
(1)Project Description
The Micro: Bit main board V2 comes with a nRF52833 processor (with a
(2)Experimental Preparation:
187
Import Hex profile (How to import?)
(3)Procedures:
computer first, and then click “Download pairing HEX file”to download
the Micro: Bit firmware to a folder or desk, and upload the downloaded
188
189
190
Search “micro bit”in your App Store to download the APP micro:bit.
Connect your Apple device with Micro: Bit main board V2:
Firstly, turn on the Bluetooth of your Apple device and open the APP
Please make sure that the Micro: Bit main board V2 and your computer are
191
Secondly, click“Pair a new micro:bit”;
192
Following the instructions to press button A and B at the same time(do not
release them until you are told to) and press Reset & Power button for a
few seconds.
Release the Reset & Power button, you will see a password pattern shows
on the LED dot matrix. Now , release buttons A and B and click Next.
193
194
195
Set the password pattern on your Apple device as the same pattern
Still click Next and a dialog box props up as shown below. Then click "Pair".
196
A few seconds later, the match is done and the LED dot matrix displays the
"√" pattern.
197
198
After the match with Bluetooth, write and upload code with the App.
Click “Create Code” to enter the programming page and write code.
199
200
201
Name the code as “1 “and click to save it.
202
Click the third item“Flash”to enter the uploading page. The default code
program for uploading is the one saved just now and named "1" and then
203
204
205
If the code is uploaded successfully a few seconds later, the App will
emerge as below and the LED dot matrix of the Micro: Bit main board V2
206
Projects above all conduct with the built-in sensors and the LED dot matrix
of the main board while the following ones will carry out with the help of
(Attention:to avoid burning the the Micro:bit main board V2, please
remove the USB cable and the external power from the board before
fix it with the shield of the car; likewise, the USB cable and the external
power should be cut from the main board before disconnect the shield
207
Project 13:Colorful Lights
(1)Project Description
This module consists of a commonly used LED with 7colors but in white
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
208
(3)Test Code
Code1
Code path:
13:Colorful Lights-1.hex
to“on start”;
Copy once;
209
Compete Program:
210
Code 2:
211
Hex file KS4031(4032) folder/Makecode Project 13:Colorful
13:Colorful Lights-2.hex
to“forever”;
Copy once;
(2) Click“Basic”to find and drag and tap the little triangle
to choose “1 second” ;
212
;
Complete Program:
213
(4)Test Results:
RGB lights of smart car emit red, green, blue, indigo, dark red, yellow and
cyclically.
214
Project 14:WS2812 RGB LEDs
(1)Project Description
The driver shield cooperates 4 pcs WS2812 RGB LEDs, compatible with
micro:bit board and controlled by P8. In this lesson, we will make RGB LEDs
display different colors by P8. In this lesson, 3 sets of test code are
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
(3)Test Code
Code 1:
215
File Type Path File Name
(GRB format)”
to P8.
216
Enter“Neopixel”to move block“strip show color red” into “forever” block
respectively set to orange, yellow, green, blue, indigo, violet, purple and
white.
Tap the triangle icon to select orange, yellow, green, blue, indigo, violet,
217
Complete Code
218
219
.“on start”: command block runs once to start program.
Set strip to Neopixel at pin P8 with 4 leads as RGB
Turn off 4pcs WS2812 RGB lights
The program under the block“forever”runs cyclically.
All RGB lights show red color
Delay in 1000ms
All RGB lights show orange color
Delay in 1000ms
All RGB lights show yellow color
Delay in 1000ms
All RGB lights show green color
Delay in 1000ms
All RGB lights show blue color
Delay in 1000ms
All RGB lights show indigo color
Delay in 1000ms
All RGB lights show violet color
Delay in 1000ms
All RGB lights show purple color
Delay in 1000ms
All RGB lights show white color
Delay in 1000ms
220
Code 2:
(GRB format)”
221
b. Place it into“on start”block,
to P8.
Change 4 into 3
3...do”
222
Place it into“for index from 0 to 3...do”block
block
223
Replicate code string for eight
Click red to respectively choose orange, yellow, green, blue, indigo, violet,
224
Complete Code:
225
“on start”: command block runs once to start program.
Strip shows
Delay in 100ms
Strip shows
Delay in 100ms
Strip shows
Delay in 100ms
226
227
.For index from 0 to 3, execute the program under do block
Turn off 4 pcs WS2812 RGB lights
Set the index of WS2812 RGB lights to green color
Strip shows
Delay in 100ms
For index from 0 to 3, execute the program under do block
Turn off 4 pcs WS2812 RGB lights
Set the index of WS2812 RGB lights to blue color
strip shows
Delay in 100ms
For index from 0 to 3, execute the program under do block
Turn off 4 pcs WS2812 RGB lights
Set the index of WS2812 RGB lights to indigo color
Strip shows
Delay in 100ms
For index from 0 to 17, execute the program under do block
Turn off all RGB on strip
Set the index of WS2812 RGB lights to violet color
228
For index from 0 to 3, execute the program under do block
Turn off 4 pcs WS2812 RGB lights
Set the index of WS2812 RGB lights to violet color
Strip shows
Delay in 100ms
For index from 0 to 3, execute the program under do block
Turn off 4 pcs WS2812 RGB lights
Set the index of WS2812 RGB lights to purple color
Strip shows
Delay in 100ms
For index from 0 to 3, execute the program under do block
Turn off 4 pcs WS2812 RGB lights
Set the index of WS2812 RGB lights to white color
Strip shows
Delay in 100ms
229
Click“JavaScript" to switch into the corresponding JavaScript code:
230
Code 3:
(GRB format)”
231
c. Signal end P8 of WS2812 RGB is controlled by P8 of micro:bit . So we set
to P8.
Click“Variables”→“Make a Variable...”
232
Move block“set B to 0”into“for index from 0 to 3...do”block,
Click B to choose R
233
Tap“Neopixel”and move“strip clear”into“for index from 0 to 3...do” block.
Set to 500ms.
234
Click“Neopixel”to move“strip show”block under “pause(as) 500”
235
Complete Code:
236
“on start”: command block runs once to start program.
Set strip to Neopixel at pin p8 with 4 leads as RGB(GRB format)
Set variable R to 0
Set variable G to 0
Set variable B to 0
The program under the block“forever”runs cyclically.
When the value of index is in 0-3, execute the program under do block
(4)Test Results:
237
WS2812RGB LEDs light up a different color a time cyclically.
Project 15:Servo
(1)Project Description
then detect the distance between the car and the obstacle, so as to control
the car to avoid the obstacle. If other microcontrollers are used to control
the rotation of the servo, we need to set a certain frequency and a certain
width of pulse to control the servo angle. But if the micro:bit main board is
used to control the servo angle, we only need to set the control angle in
238
the development environment where the corresponding pulse will be
automatically set to control the servo rotation. In this project, you will learn
how to control the servo to rotate back and forth between 0° and 90°.
housing, circuit board, core-less motor, gear and position sensor. Its
working principle is that the servo receives the signal sent by MCU or
receiver, and produces a reference signal with a period of 20ms and width
of 1.5ms, then compares the acquired DC bias voltage to the voltage of the
the ground, the red one is the positive wire, and the
The rotation angle of servo motor is controlled by regulating the duty cycle
corresponds to the rotation angle from 0° to 180°. But note that for
different brand motor, the same signal may have different rotation angle.
239
More details:
(3)Parameters:
◆ No-load speed: 0.12 ± 0.01 sec / 60 (DC 4.8V) 0.1 ± 0.01 sec / 60 (DC
6V)
◆ No-load current: 200 ± 20mA (DC 4.8V) 220 ± 20mA (DC 6V)
240
◆ Stopping torque: 1.3 ± 0.01kg · cm (DC 4.8V) 1.5 ± 0.1kg · cm (DC
6V)
(4)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
(5)Test Code:
Code path:
241
Hex file KS4031(4032) folder/Makecode Project 15:Servo.hex
Tutorial/Makecode Code/Project
15:Servo.hex
“on start” ;
; put into
242
;
243
Copy once and change the “+”
of to “-”: .
Complete Program:
244
① The "on start" command block runs only once to
start the program.
⑦ Delay in 10ms
245
(6)Test Results:
After uploading the test code and dial POWER switch to ON end, the servo
246
Project 16:Motor
(1)Project Description
247
Micro:bit motor driver shield comes with PCA9685PW and TB6612FNG
chip. In order to save the IO port resource, we control the rotation direction
Front
248
Back
249
250
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
251
➢ Connect micro:bit to computer by USB cable
(3)Test Code:
Code 1:
16:Motor-1.hex
252
behind speed to choose 75 ;
in 2000ms ;
253
Complete Program:
① In the "forever" instruction block, the program runs
cyclically.
② Set the front left motor speed to 75, and rotate
clockwise.
③Set the speed of the rear left motor to 75 and the
direction to rotate clockwise.
④Set the front right motor speed to 75 and the direction
to rotate clockwise.
⑤Set the right rear motor speed to 75 and the direction to
rotate clockwise
⑥The delay time is 2000 milliseconds
⑦4 motors stop rotating
254
Code2:
Code path:
16:Motor-2.hex
255
Or you could edit code step by step in the editing area.
256
And then put they all in forever and add .
Complete Program:
258
(4)Test Results:
Download code 2 to micro:bit board, the car goes forward for 2s, turns
back for 2s, turn left for 2s, turn right for 2s and stops for 2s and repeats
this pattern.
259
Project 17:Line Tracking Sensor
(1)Project Description
The motor driving board of the Keyestudio 4WD Mecanum Robot Car
receiving tube; high level(1) will be output when smart car runs along black
line.
When smart car drives on the white ground, TCRT5000 IR tube will emit IR
260
(2)Working Principle:
When the car runs above a white road, the infrared transmitter tube
installed under the car emits infrared signals to detect the road and the
receiver tube receives signals sending back. Then the output end outputs
The 2-way tracking sensor integrated port on the 4WD Mecanum Robot
Car is connected to the collection port of G ,5V ,P1 and P2 on the micro:bit
left TCRT5000 infrared pair tube on the sensor is controlled by P1, and the
After putting a white paper on the bottom of the 4WD Mecanum Robot
Car,we rotate the two potentiometers on the 2-way tracking sensor. When
the indicator light on the sensor module is on, pick up the car to make the
two wheels on the 4WD Mecanum Robot Car separate. The height of the
white paper is about 1.5cm, the indicator light on the sensor module is off,
(3)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
261
➢ Dial power switch to ON end
(4)Test Code:
Code1:
Sensor-1
262
Enter“Advanced”→“Serial”→
Leave it into“forever”block.
The right tracking sensor is controlled by P14. Then change P0 into P14
and“x”into“digital signal”.
“forever”;
263
Copy once and change Leftto Right
Drag ;
in 200ms:
Complete Program:
264
① The "on start" command block runs only once to start
program.
Open CoolTerm, click Options to select SerialPort. Set COM port and
The CoolTerm serial monitor displays the digital signals read by right line
tracking sensors.
265
Code 2:
Code path:
266
Sensor-2
“0”behind “to”;
267
and change the second “LL”to “RR”, and ”Left”to ”Right”:
268
Copy“LL”1 once and place it to the right of“and”;
“0”to“1”:
(6)Click“Basic”to find and drag“show leds”to the first”then”; Click the blocks
to form pattern“←”:
269
(7)copy“LL=0 and RR=1”once and place it behind the first“else if”,
unchanged:
270
(8) Click“Basic”to find and drag“show leds”to the second “then”;
271
(9)Copy“LL=1 and RR=0”once and place it to “else if” and change the
272
(10)Click“Basic”to find and drag“show leds”to the third else;
273
(11)Click“Basic”to find and drag“show leds”to else;
274
Complete Program:
275
① The "on start" command block runs only once to s
program.
②Set the variable LL to 0
③Set variable RR to 0
⑧The left side of the LED dot matrix displays the "←"
276
(5)Test Results:
Download code 2 to the micro:bit, when only the left TCRT5000 infrared
pair tube on the line tracking sensor detects a white object, the micro bit
LED dot matrix displays a "←" pattern, and the indicator light on the left
When only the right TCRT5000 infrared pair tube on the sensor detects a
white object, the micro bit LED dot matrix displays a "→" pattern, and the
indicator light on the right side of the tracking sensor lights up;
277
17.2: Line Tracking Smart Car
(1)Project Description
In this lesson we will combine line tracking sensors with a motor to make a
The micro:bit board will analyze the signals and control smart car to show
The smart car will make different moves according to the value received by
278
LOW(0) LOW(0) Stop
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
(3)Flow Chart:
279
Start
Yes
The left sensor
detects 1, the right No
Turn right one detects 0
Yes
Both of sensors
Turn left No
detect 0
Yes
Stop Go forward
(4)Test Code:
Code path:
280
and to decide:
;change“doSomething”to “car_forward”,
“car_back”,“car_left”,“car_right”respectively:
281
282
Click “Functions”of ”Advance”to find and drag to the first
283
Complete Program:
284
①forward function
speed of 40
at a speed of 40
speed of 40
speed of 40
⑥Backward function
40
40
is 40
40
60
60
the speed is 85
the speed is 85
the speed is 85
speed is 85
speed is 60
speed is 60
285
286
Click“JavaScript"to view the corresponding JavaScript code:
(5)Test Results:
Download code to micro:bit and dial POWER to ON end, line tacking car
the width of black line should be larger than the width of line tracking
sensor.
287
Project 18: Ultrasonic Follow Smart Car
(1)Project Description
bats do. It offers excellent non-contact range detection with high accuracy
As the above picture shown, it is like two eyes. One is transmitting end, the
The ultrasonic module will emit the ultrasonic waves after trigger signal.
When the ultrasonic waves encounter the object and are reflected back,
object from the time difference between trigger signal (TRIG)and echo
signal(ECHO).
288
According to the above wiring diagram, the integrated port of the
micro:bit motor drive backplane. The Trig (T) pin is controlled by P15 of the
(2)Working Principle:
Pull down TRIG then trigger high level signals with least 10us
After triggering, the module will automatically send eight 40KHz ultrasonic
289
The propagation speed of sound in the air is about 340m/s, therefore,
distance = speed * time, because the ultrasonic wave emits and comes
(3)Parameters:
◆ Precision: up to 0.2cm
◆ Output echo signal: output TTL level signal (high), proportional to range
(4)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
290
Import Hex profile (How to import?) , or click“New Project”and drag
(5)Test Code:
291
0 on the right side of“serial write value x=0”and change the x on the left
place it behind
Complete Program:
292
① The "on start" command block runs on
(6)Test Results:
Download code to micro:bit, keep USB cable connected, dial POWER switch
293
The monitor shows the distance between the obstacle and ultrasonic
sensor(as shown below). When the distance is less than 10cm, the passive
294
Open CoolTerm, click Options to select SerialPort. Set COM port and
295
296
18.2: Ultrasonic Avoidance Car
(1)Project Description
Its principle is to detect the distance between the car and obstacle by
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
297
➢ Open online Makecode editor
(3)Flow Chart:
298
Start
Distance<20cm?
NO
YES
STOP Go forward
Left distance>Right
distance NO
YES
Servo rotates Servo rotates
90°, turn 90°, turn
left right
(4)Test Code:
Code path:
299
File Type Path File Name
Car.hex
300
(5) Click“Variables”to find and drag“set distance to 0”to“forever”;
the”to”:
301
(7) Click Funtionsto of “Advance”to find and drag ;
302
(8) Click“MecanumRobot”to find and drag and
Copy once;
Copy once;
303
(9) Copy once;
unchanged:
304
(10) Click“Logic”to find and drag“if true then...else”;
305
(11) Click Funtionsto of “Advance”to find and drag ;
300:
306
(12) Change to and place it in the first
“else”:
307
(11)Click “Funtionsto” of “Advance”to find and drag ,
308
Complete Program:
309
310
Click“JavaScript" to view the corresponding JavaScript code: :
311
(5)Test Results:
When the obstacle distance is greater than 20cm, the car goes forward ; on
312
18.3: Ultrasonic Follow Smart Car
(1)Project Description
In previous lesson, we’ve learned the basic principle of line tracking sensor.
The ultrasonic sensor detects the obstacle distance and control the motion
status of car.
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
313
➢ Connect micro:bit to computer by USB cable
(3)Flow Chat:
314
Start
YES
the front detected
Go back
distance<40cm? NO
Stop YES
Go forward Stop
(4)Test Code:
Code path:
Car.hex
315
Or you could edit code step by step in the editing area.
distance to 0”:
316
(2) Click“Logic”to find and drag“if true then...else”to“forever”;
317
(6)change the 10 to 20, car_back to car stop:
318
Place car stop to the last”else”:
Complete Program:
319
Click“JavaScript" to view the corresponding JavaScript code: :
320
(5)Test Results:
321
Project 19:IR Remote Control
(1)Project Description
pilot code, user code, user inverse code, data code, and data inverse code.
322
The time interval of the pulse is used to distinguish whether it is a 0 or 1
The user code of the same remote control is unchanged. The data code can
When the remote control button is pressed, the remote control sends out
an infrared carrier signal. When the IR receiver receives the signal, the
program will decode the carrier signal and determines which key is pressed.
The MCU decodes the received 01 signal, thereby judging what key is
made by the receiver has only three pins, signal line, VCC and GND.
According to the picture above, the integrated port of the infrared receiver
is connected to the G port on the motor driver board and controlled by the
323
(2)Parameters:
➢ Interface: 3PIN
➢ Frequency: 38khz
(3)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
(4)Test Code:
324
Hex file KS4031(4032) folder/Makecode Project 19.1:Decode IR
19.1:Decode IR Remote
Control.hex
select P9.
box,
325
Then drag out“set val to 0”block into“forever”block.
Put it into“forever”block
Change“x”into“IR”
Leave it into“forever”block
326
Complete Program:
Connect IR receiver to P9
Delay in 1000ms
327
Code explanation: when the buttons are not pressed, the serial monitor
displayed.
Notes:
Make sure IR remote is good before test. There is a tip for you to check it.
Open the cellphone camera , make IR remote control point at camera and
press button. The remote control is good if you see the purple flashing
Download code to micro: bit board and don’t plug off USB cable Click
328
Make IR remote control point at IR receiver and press the button, the serial
329
Open CoolTerm, click Options to select SerialPort. Set COM port and
330
The key value is displayed as for your reference:
331
19.2:IR Remote Control
332
(1)Project Description
remote smart car. Its principle is to control the motion of car by sending
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
Note: The infrared sensor and infrared remote control should not be
normally.
333
(3)Flow Chart:
Start
Val2=70? NO
Val2=68? NO
YES
YES Val2=67? NO
Go forward
Turn left
Val2=21? NO
YES
YES
Turn right Val2=64?
Go back
YES
Stop
(4)Test Code
Code path:
334
File Type Path File Name
(1)Create four functions controlling the car to move forward and back
335
(3)Click“Variables”then click“Make a Variable...”, the dialog box“New
“val”;
Click the little triangle behind the first val2 to choose “val”;
little triangle behind val2 to choose val; Click“IrRemote”to find and drag
336
“=”into“true”;
the right side of “=”remain unchanged; click the little triangle behind
“=”to choose“≠”;
337
Find and drag “=” to “true”;
338
(9)Click“Functions” of“Advance”to find and drag 指 to
339
(10)Copy “val2=70”once and place it behind the first “if”;change the 70
340
behind “=” to 68;
341
second “then” :
“then”:
342
(13)Copy“val2=67”once and put it behind “=” of the third “else if ;
343
(14)Copy “val2=21”once and place it behind the fourth “else if “;change
344
Complete Program:
345
① The "on start" command blo
program.
②Connect the IR receiver to P9
③Set the variable val to 0
④Set the variable val2 to 0
346
(5)Test Results:
Make IR remote control point at micro:bit and press the button to control
button makes smart car move forward, stands for turning left,
347
(How to download? How to quick download?)
smart car are supposed less than 5m, during the test.
(1)Project Description
Micro:bit main board comes with a built in Bluetooth which can be used to
communicate with it. And the Micro:bit can also be controlled by Bluetooth
Android system ans IOS system. And we have designed two Bluetooth App
348
The connection of the Bluetooth on the board with these two Apps is
similar. In this lesson, we will introduce the functions of all keys and
patterns on the Apps and control the smart car via Bluetooth App.
(2)Experimental Preparation:
➢ Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
As the Bluetooth and extension radio can’t work together, therefore, their
Therefore, remove extension(s) and add Bluetooth please if you see the
349
(3)Test Code:
Code Path:
*****************************************************************************
350
Click“Bluetooth”→“on bluetooth connected”
block.
*****************************************************************************
box.
block.
change 0 into 1.
351
*****************************************************************************
do...”block.
352
And combine variable“rec_data”with“serial write string”block.
as follows:
353
Click“Bluetooth”to drag out“on bluetooth disconnected”.
Complete Program
354
355
“on start”: command block runs once to start program.
Connect Bluetooth
executed.
Disconnect Bluetooth
356
(4)Test Results:
If you drag blocks step by step, you need to set as follows after finishing
test code.
Click → →
However, you could skip this step if you directly import test code.
After setting, download code to micro:bit board, don’t plug off USB
357
For IOS System:
mecanum_robot;
appears on the APP interface, and click "OK" in the dialog box.
d. First turn on the Bluetooth of the mobile phone/iPad, and then click the
connect button (control) in the upper left corner of the APP interface to
a. Use the scanning function in the browser to scan and identify the QR
mecanum_robot application.
358
B.Click“Allow allow”to enter Installation Diagram; click“install”to install
the App ;
phone desktop to open the APP, and a dialog box appears. In the dialog
box, click "Allow" to turn on the Bluetooth of the mobile phone. You can
359
Click on the upper right corner to search for
Open CoolTerm, click Options to select SerialPort. Set COM port and
360
Point at micro:bit board and press the icons on APP, the corresponding
Through the test, we get the function of every icon, as shown below:
361
362
20.2: Multi-purpose Smart Car
(1)Project Description
function.
(2)Experimental Preparation:
Insert micro:bit board into slot of keyestudio 4WD Mecanum Robot Car
363
Dial power switch to ON end
As the Bluetooth and extension radio can’t work together, therefore, their
Therefore, remove extension(s) and add Bluetooth please if you see the
Code path:
364
Hex file KS4031(4032) folder/Makecode Project 20.2:
Car.hex
Complete Code:
365
366
Click“JavaScript" to view the corresponding JavaScript code: :
367
(4)Test Results:
368
Download code to micro:bit board, dial POWER to ON end, and connect
the Bluetooth, then you can control the car via the Bluetooth App of
mecanum_robot.
9. Resources:
https://microbit-micropython.readthedocs.io/en/latest/tutorials/introducti
on.html
MicroPython:
https://docs.openmv.io/reference/index.html
ustruct library:
https://docs.openmv.io/library/ustruct.html
math library:
https://docs.openmv.io/library/math.html
utime(sleep_us,tick_us) library:
https://docs.openmv.io/library/utime.html#
369