MaxBot - Robotics With Microbit
MaxBot - Robotics With Microbit
STARTER GUIDE
欢迎加入 DF 创客社区 www.DFRobot.com.cn 2 / 101
Contents
Contents ..................................................................................................................................................... 2
Max:bot ...................................................................................................................................................... 6
An introduction to Max:bot .............................................................................................................................6
How to define a robot? ....................................................................................................................................6
Component list of Max:bot ..............................................................................................................................7
An brief introduction to Micro:bit .............................................................................................................. 8
What is Micro:bit? ..............................................................................................................................................8
How to program Micro:bit............................................................................................................................. 10
Makecode graphical programmable ................................................................................................... 10
Micropython code programming ........................................................................................................... 11
How to graphical program Micro:bit through Makecode? .................................................................. 11
Open makecode ........................................................................................................................................ 11
The programming interface ..................................................................................................................... 12
Download the program and upload to micro:bit ............................................................................... 14
Chapter 1: Max:bot Run ........................................................................................................................ 16
Goals: ............................................................................................................................................................ 16
Digital modules ............................................................................................................................................ 16
1.1 Go forward ................................................................................................................................................ 17
Key information ........................................................................................................................................... 17
Program ........................................................................................................................................................ 17
Exercises ........................................................................................................................................................ 19
1.2 Go in circles ............................................................................................................................................... 19
Key information: .......................................................................................................................................... 19
Program ........................................................................................................................................................ 20
Exercise ......................................................................................................................................................... 23
1.3 Round in squares ...................................................................................................................................... 23
Key information ........................................................................................................................................... 23
Program ........................................................................................................................................................ 24
Exercise ......................................................................................................................................................... 27
Chapter 2: Smart Max:bot ....................................................................................................................... 27
Goals: ............................................................................................................................................................ 28
欢迎加入 DF 创客社区 www.DFRobot.com.cn 3 / 101
Program ........................................................................................................................................................ 95
Exercise ....................................................................................................................................................... 101
Max:bot
An introduction to Max:bot
Max:bot, an easy-to-use mobile platform with the best designed interfaces,
can provide various functions for its users. It can be perfectly functioned when
capabilities of a robot. However, what may surprise you more is the all-metal
computing power. Just like living creatures, robots too have their own “organs”:
The brain: Micro:bit is the brain. With its own logical system, the board can
thus we get the sensory system. For instance, a Smart Grayscale Sensor and a
Digital Crash Sensor can be used as the eye and the hand to receive outside
information.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 7 / 101
The executive system: This system can change our environment or send out
LED strips and digital speaker modules can be connected to Max:bot for
sending out massages. Additionally, there are another 25 red leds mounted in
connected
Micro:bit
Raspberry Pi
Tracking(Following) Sensor
P5、P11
Motor P8、P12
Connect all the components listed above to the board below, we can then
have the body of Max:bot.
What is Micro:bit?
Micro:bit is an easy-to-use, powerful and cost effective pocket-sized
microcontroller designed for kids and beginners learning how to program,
letting them easily bring ideas into DIY digital games, interactive projects and
robotics.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 9 / 101
Thanks to its extensive I/O ports and hardware support, Micro:bit is well suited
Smart module
l A pocket-sized microcontroller
inclusive interfaces.
Users can drag and place the relevant modules in the webpage to read data
of sensors, and to process the data quickly through certain logic functions
robot control.
Http://microbit.dfrobot.com.cn/index.html or,
Https://makecode.microbit.org/#
Open makecode
Http://microbit.dfrobot.com.cn/index.html or,
欢迎加入 DF 创客社区 www.DFRobot.com.cn 12 / 101
Https://makecode.microbit.org/#
When using it for the first time, no program can be found on the interface.
Makecode has the memory function. So whenever you open it, you will find it
Simulation window: Simulates the operating status of micro: bit. During the
process of programming, you can always check how your program looks like
the through the window.
Function area: Where you can find all the function blocks, including input,
output, loop, logic, etc.
Programming area: Dragged the blocks from “Function area”, stack them
up and build your program here.
Naming area: You can name your project here. The default is “Untitled”.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 14 / 101
already been obsessed with his shiny skin. You must want to play with him
now. But he is a newborn that even cannot make one simple move. God
knows how much he has dreamt to jump and dance like you do. He really
Goals:
1. How to run the wheels?
Digital modules
Digital modules Images Functions
欢迎加入 DF 创客社区 www.DFRobot.com.cn 17 / 101
Max:bot to go forward
and rotate.
1.1 Go forward
Key information
Function Image(s) Function(s)
block(s)
the motors.
Program
(2) The “on start” module will not be used in this part. So we have to
delete it. We just need to drag and drop it to the function area. It will
other functions.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 18 / 101
(3) Find the “servo write” function from “Pins” in the function area. This
(4) Put the “servo write” function into the “forever” loop.
Please note: the left wheel should be connected to P8, and the right to
P12.
(5) Now please download it to Max:bot. Wow! Can you see that? Max:bot
is going forward!
欢迎加入 DF 创客社区 www.DFRobot.com.cn 19 / 101
After downloading, you have to remove the USB cable from the computer.
If Max:bot still not move, please check if you have switched it on or not.
Exercises
It is you that allow Max:bot to move forward. He really appreciates it. But he
also wants to know how to go backward. Will you help him with this?
Tips: the number in the “servo write” function controls the speed.
1.2 Go in circles
Key information:
Function Image(s) Function(s)
block(s)
independent sub-loop.
Please note: the “function” and “call function” are all lie in
“Advanced” => “Functions”. But both of them are not listed in it
directly. The way to find them goes like:
Please remember that the “call function” appears only when the
“function” is created.
Program
(1) Start a new project and name it as “ Round in circles”
Click “Projects”.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 21 / 101
otherwise makecode would save it directly into the last project file.
Click “Make a Function” and name it as: Rotate. Then you will find the
same time it is created, the “call function” appears in the “Functions” of the
function area.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 22 / 101
Before programming, we will need to first get familiar with the “differential
steering” principle.
In our daily life, what enables a car to turn is the different rotate speed
of the driving wheels. Both the clutches that are mounted on the left
and right axle shafts and the brake can be used to control the driving
Therefore, the key to success is to rotate the two wheels in different speed.
The “180” is the top clockwise rotation speed, whereas the “0” is the top
place the “call function” from “Functions” into the “forever” loop. Thus the
(4) Combine all function blocks listed above together, we will have the
Do not forget to remove the USB cable and switch Max:bot on.
Exercise
We have learnt how to make Max:bot rotate clockwise. Can you make it
Key information
Function Image(s) Function(s)
block(s)
欢迎加入 DF 创客社区 www.DFRobot.com.cn 24 / 101
period of time.
Program
(1) Start a new project and name it “Round in squares”
(2) Create another two sub-loops and name them as “Go” and “Turn
As we all know that if one would like to round in squares, he/she must be firstly
walk straight for a while (like 1 minuet), then turn 90 degrees and keep
walking forward for another minuet... These moves will be repeated until
in previous parts that the “servo write” function can be used to control
this part. Set both the values as “0” to keep the two wheels rotate in
the same speed. And then put the “servo write” into “function(Go)”.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 25 / 101
Max:bot rotate. But here, we have to adjust the values to make it turn
90 degrees only. Set P8(the left wheel) as “0”, and P12(the right wheel)
Compared with the “function(Rotate)”, the values “0” and “90” set in the
The “90” in P12 means the right wheel rotates 0 degree. The “0” in P8 means
the left wheel rotates at the top anticlockwise speed. Thus, Max:bot turns
right.
(5) Place both the “call function(Go)” and the “call function (Turn
around)” into the “forever” loop. The final program goes as:
move forward and turn. We need the “pause” function here to set the time.
You can find it in “Basic” of the function area. Place it into the “forever” loop.
Please note:
Different batteries output different voltages. So the “2000” and “700” here
are just used for a reference. You have to try and adjust them based on
欢迎加入 DF 创客社区 www.DFRobot.com.cn 27 / 101
the actual situation. Remember what we have just said: No pain no gain.
(6) Combine all the functions listed above together, the final program is as
following. Make sure you have made every step correctly and then
download it to Max:bit.
Exercise
Once you have made it round in squares, it is a piece of cake to round it in
anywhere you want it to go. But have you feel a little bit more frustrated that
欢迎加入 DF 创客社区 www.DFRobot.com.cn 28 / 101
there always has something to block its way, like a desk or a closet. Don’t
worry, in this chapter, we will teach Max:bot how to avoid these obstacles.
Goals:
1. How to use the Digital Crash Sensor?
Digital Modules
Digital Module(s) Image(s) Function(s)
button, detect
obstacles. As the
sensors (circled in
red) connected to
Max:bot separately.
Key information
Function Image(s) Function(s)
block(s)
0).
Program
(1) Start a new project and name it as “the shy Max:bot”
(2) Find the “if then” function from “Logic” in the function area and place
If the logic statement to the right side of “if” is met, the function to the right of
Besides “=”, there are many other operators, like “>”, “<”, “¹”, “£”, “³”,
whether the digital crash sensors are touched or not. Connect one of
shy and with his heart speeds up. But how can we make his heart really
beat? The function “show icon” does the job. You can find it in “Basic”
As has shown in below image that there is a micro triangle lies at the
top right of the “show icon”. Click it and choose the smaller heart icon.
function and another bigger heart icon. By putting together all the
Now when you touch Max:bot, he will then show you his heartbeat.
Exercise
Needless to say, Max:bot is a very nice companion. We have already
created his heartbeat. Now we want to make him a smile face when he is
untouched.
We will use the “if else” function to make him smile. You can also find it in
Compared with the “if then”, there is an additional “else” in the “if else”.
What is it?
As we have learnt in previous part that, in the “if then” function, If the logic
statement to the right side of “if” is met, the function to the right of "then"
While in the “if else” function, if the logic statement on the right side of “if” is
Key information
Function Image(s) Function(s)
block(s)
below:
else” function.
example:
2. Which means:
executed.
Program
(1) Start a new program and name it as “escape the maze”
If the left digital crash sensor is touched, Max:bot will then turn to the
right;
If the right digital crash sensor is touched, Max:bot will then turn to the
left.
(3) Some above learnt programs will be combined in this part to help
Max:bot escape the maze. Such as: turn left, turn right, go straight, etc.
below in the “pause” function is just used for a reference. You have to
Exercise
Max:bot, a really fast learner, now has made another step forward! Can you
remember the “heartbeat” we made for him? How about to make him show
Tips: You may need the help of the “show leds” function.
In previous chapters, since Max:bot is, like an alive creature with eyes, able to
recognize and avoid obstacles, what else can we explore about his sensory
system?
You will be surprised that Max:bot can even sense the brightness of light. In
Goals
1. How to use the light sensor?
Digital modules
Digital module(s) Image(s) Function(s)
Micro:bit is used to
an on-board light
sensitive component,
their eyes for protection. Whereas being in surroundings with poor lights, they
are not able to distinguish objects. Here come the questions: it is what that
influences the light brightness. How the colors of lights influence its brightness?
To make above clear, we should ask Max:bot for help. As the saying goes:
learn to walk before you run. So we will need first to use Micro:bit to transfer
Key information
Function Image(s) Function(s)
block(s)
strong.
Program
(1) Start a new program and name it as “adventure to brightness”.
(2) Find the “show number” function from “Basic” and place it into the
(3) As we have mentioned above that the “show number” function can
be used to show the number that has been read by the “light level”
function. So, in this step, we need first to find the “light level” function
from the “Input” in the function area, and then place it to the “show
Exercise
There are different rooms with different lights in your house, why not go and
detect their brightness? You can record them in the table below.
right? As have learnt the principle about how can Max:bot sense the
Key information
Function Image(s) Function(s)
block(s)
“if else”
means:
met.
Program
(1) Start a new program and name it as “the moth robot”
(2) When the brightness reaches a certain range of value, the moth robot
will go forward to the light. Whereas stay and rotate if the value is not
(3) In this part, the operator “=” will be used to judge if the brightness
reaches the set value or not. And the “servo write” function is used to
make the robot go forward or rotate. The “if else” function here is used
putting all the functions listed above together, we will have the final
program as below:
欢迎加入 DF 创客社区 www.DFRobot.com.cn 45 / 101
Please note: the value of brightness should neither be too large nor too
If the value is too large, the moth robot will not go forward till a
If the value is too small, the moth robot will then not likely to stop
moving forward.
(4) Download the final program to Max:bot. You can now play a light
Exercise
Let’s hold a race for the moth robot player.
You can invite your friends to join the race. Each of you will use the same
electric torch to guide the moth robot move forward. The winner goes to the
person that completes a lap in the shortest time. The starting line stands a red
flag.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 46 / 101
Tips: Maintain its speed within a reasonable range holds the key to success.
digital crash sensors and the light sensor) to avoid obstacles and sense the
brightness of light. However, have you ever noticed that there are another
They are eyes with superpower. But you have to promise me to keep it as our
secret. This pair of eyes are the secret weapon of Max:bot. Let’s learn them
together.
Goals:
1. How the ultrasonic sensor works?
Digital modules
Digital module(s) Image(s) Function(s)
obstacles.
good companion. Once we have Max:bot, all other measuring tools, like
rulers, tapes, etc., can be thrown away. In short, Max:bot can measure
them can be heard by our ears, while the others cannot. Scientists named the
vibrating times per second as the sound frequency with its unit named as
Hertz. Almost every human is able to hear the sound frequencies ranging from
20 to 20000 Hertz.
However, most of us is not able to hear those sound frequencies that are
higher than 20000 Hertz or lower that 20 Hertz. Therefore, for those sound
frequencies that are higher than 20000 Hertz, scientists have another name for
As we have learnt above that the ultrasonic sensor can, through the air, send
the sent out ultrasonic will be bounced back immediately and received by
the receiving end. Therefore, the ultrasonic sensor can calculate the distance
through the formula: S=340t/2. Among which, “S” is the distance; “340” means
ultrasonic travels at 340 meters per second in air; “t” is the total amount of
time; “/2” means the time we need for the calculation is the time the
ultrasonic travels to the obstacle. But the “t” (the total amount of time) is the
time both for transmitting and receiving, so the “t” need to divide 2.
You may now have been convinced that Max:bot is a professional and
powerful tool. He can even calculate the distance within one second! Let’s
try it!
Key information
Function Image(s) Function(s)
block(s)
right of “unit”.
Program
(1) Star a new program and name it as “ultrasonic measures distance”
The function area has listed some basic functions. However, for
Click “Add package” and search “sonar”. Then click the package named
(3) We need first to place the “show number” function from “Basic” into
the “forever” loop. Then put the “ping unit” function from “Sonar” in
The image above is from the ultrasonic sensor. Among which, the
P1, and “ECHO” the receiving end to P2. While programming, in the
欢迎加入 DF 创客社区 www.DFRobot.com.cn 52 / 101
“ping unit” function, we should change the Pin of “trig” to P1, and the
“echo” to P2.
(4) By putting all the functions listed above together, we will have the final
Exercise
Above we have learnt how to use Max:bot to measure a distance. Do you
have any idea about how to use it measure your height? Just try it!
欢迎加入 DF 创客社区 www.DFRobot.com.cn 53 / 101
Tips: To make the calculation more accurate, you may need to:
1. Pay attention to where and what direction the ultrasonic sensor
locates.
2. To avoid major deviations, it is better to adjust Max:bot within
10cm.
almost anywhere at any time. Cars make our life more convenient, but at the
same time, put us in danger. How can we help drivers to be more sensitive
Key information
Function Image(s) Function(s)
block(s)
欢迎加入 DF 创客社区 www.DFRobot.com.cn 54 / 101
dynamic effect.
“item” equals 0.
Program
(1) Start a new program and name it as “car safeguard”
(2) Item
transform the variable brightness into a certain value. Thus we have the
“set item to” function. Among which, the “item” in the middle is the
detected variable. The whole function means: set the value of the
Find the “set item to” function from “Variables”, and place it into the
“forever” loop.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 55 / 101
In this part, the data that has been detected in real time is the
distance that the ultrasonic travels. Therefore, we need to set the value
how to use the “ping unit” function to calculate the distance, so, in this
part, the “ping unit” function should be placed in the “set item to”
function.
Since the value of the variable named “item” has been set, we can
now use the variable “item” directly in later parts. You can find the
(3) Once the distance between the obstacle ahead and Max:bot is
shorter than the preset value, Max:bot will then stop automatically to
It sounds like a very good idea, but how to achieve this? We can use
(4) Combine all the function blocks listed above together, the final
As you may have noticed that there are two “forever” loops. It is
should detect the value of the variable, and, on the other hand, it itself
to use two “forever” loops in this part. You can find the “forever” loop
Exercise
When driving, the car will not stop completely but to gradually slow down.
When the distance between it and the car ahead becomes closer and
“eyes” (the digital crash sensors and the light sensor) to avoid obstacles and
sense the brightness; then he has the eye on his face (the ultrasonic sensor) to
measure the distance between it and the obstacle. You may wonder if he
has any other eyes? The answer is absolutely yes. In this chapter, another eye
will be introduced. Max:bot keeps this eye toward the ground to avoid falling
down from a height. By the way, with the help of this eye, Max:bot can go
Goals:
1. How to use the line tracking(following) sensor?
Digital modules
Digital module(s) Image(s) Function(s)
欢迎加入 DF 创客社区 www.DFRobot.com.cn 59 / 101
a white background.
easy, Max:bot will never do such a stupid thing. Thanks to the line
moment.
There are three probes in the line tracking(following) sensor. But in this part,
we will use only two of them. Connect the left probe to P15 and the right to
P14.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 60 / 101
In addition, both the left and the right probes can be used as separated
infrared sensors.
Which means that both the probes can transmit and receive infrared. The
way the probe works is similar to the ultrasonic sensor’s. However, it will not
When being putting on a table, both of the probes transmit infrared. The
bounced back and receive by them. Thus, the indicator lights up and the
Whereas when Max:bot goes to the edge of the desk, the transmitted
infrared will not be bounced back. Thus, the indicator turns off and Max:bot
Key information
Function Image(s) Function(s)
block(s)
Program
(1) Start a new program and name it as “Max:bot wake up!”.
(2) In this program, we will only use the left and the right probes of the
(4) Below we have applied so many functions that have been learnt
The multiple “if else” function here is used to judge which action
Max:bot should take: The first “if then” means both the probes detect
the precipice, Max:bot will then go backward and turn left; the second
“if then” indicates that the right probe detects the precipice, Max:bot
will then go backward and turn left; the third “if else” shows the left
probe detects the precipice, Max:bot will then go backward and turn
right. The last “else” means if none of the three “if then” is met, Max:bot
By putting all the functions listed above together, the final program
Exercise
Can you find out some other objects that should be avoided falling from a
height?
Nowadays, more and more advanced tools are embraced by human beings
with opened arms. Such as the self-charging sweeping robot which can
There lines an array of probes at the bottom edge of the sweeping robot to
Once you thought of other objects that should be protected from falling
down, you can note them down in the blank below. The more the better.
·
·
·
Key information
Function Image(s) Function(s)
block(s)
Program
(1) Start a new project and name it as “trace the track”
欢迎加入 DF 创客社区 www.DFRobot.com.cn 66 / 101
(2) In this chapter, we need first to pave a black track by a black pen or a
along it.
Please note: the black track should be wide enough that both the left
(P14) and the right (P15) probes of the tracking(following) sensors can
detect it simultaneously.
programming.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 67 / 101
(5) In this program, like the final program of the last part, we use the
“function” to enable Max:bot to turn right, go forward and turn left. The
multiple “is else” function is applied to tell Max:bot when to turn left,
when to turn right and when to keep going forward. Combine all the
function blocks listed above together, we will have the final program
as below.
Download the final program to Max:bit. It will then go and trace along
Exercise
Max:bot can now travel around the world by the black track! You may not
believe it because some roads are quite complex. Are Max:bot able to trace
them down and discuss with your friends to find out the solution.
·
·
·
With one Max:bot, you can almost control everything. What if you have two
Max:bots in hand?
As we have learnt that Micro:bit is the brain of Max:bot. Other than the
another function which can realize the remote control. Let’s explore it!
Goals:
1. How to use the radio communication function?
Digital modules
Digital Image(s) Function(s)
module(s)
mounted with
the radio
module and
the
accelerometer.
6.1 Say Hi
When two Max:bots meet up with each other, what would they do? It must
The radio communication function does the job. When two Max:bots come
across each other, one of them will send out a signal via Micro:bit, while the
We will need two micro: bits in this part, one sends out message (transmitting
end), the other receives the signal (receiving end). The micro: bit
communicates over radio.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 71 / 101
We need first to get to know the three most commonly used functions under
“Radio”:
1、“set group”:
Function description: There are a total of 255 different radio channels. The
transmitter and the receiver should be set in the same group to be able to
communicate.
Please note: different radio channels should be set for different players to
There are 7 grades can be selected for radio transmit power. The higher the
Key information
Function Image(s) Function(s)
block(s)
start” will be
executed once
only.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 73 / 101
channel.
radio
loop.
power.
Program
The transmitting end
(1) Start a new project and name it as “say hi the transmitting end”
Functions that are placed into the “on start” will be executed once
only. Which means both the “set group” and the “set transmit power”
Since the Max:bot will say Hi to each other, so we need to use the
“radio send string” function to send out the “Hi” over radio.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 74 / 101
(4) Combine all the function blocks listed above together, the final
transmitting end.
(1) Start a new project and name it as “say hi the receiving end”
(2) Set the same radio channel as the transmitting end via “set group”.
(3) The ”on radio received string” function will be used to judge whether
(4) Below we use the ”if else” function to judge whether the received
Please note: “Hi” is in the form of text. So the “” function will be used in
this part to read the text. You can find it from the “Text” in the function
area.
(5) If the “Hi” is received by Max:bot via radio, the robot will then display a
smiling face. We will apply the “show icon” and the “pause” function
(6) By putting all the functions listed above together, the final program
Exercise
On some occasions, like spy films, we need to identify each other through a
One Max:bot sends out a code, like 1231; while when the other received the
code, it will then display a corresponding code, as 1321. If failed, he will then
requires you to drive the car on the screen through real body move.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 77 / 101
With Micro:bits, you can play the motion sensing game. The on-board
telling Micor:bit’s motions. Including its moving direction, angle, gesture, etc.
In the function area, we can use the “on” function from the “Input” to read
1、 “on shake”
the right.
Key information
Function Image(s) Function(s)
block(s)
not.
can be selected.
Program
The transmitting end
(1) Start a new project and name it as “sensing racing the transmitting
end”
欢迎加入 DF 创客社区 www.DFRobot.com.cn 80 / 101
(2) Use the “on start” to initial set the transmitting end.
(3) When tilting to the downside (the side without LOGO), Micro:bit
displays an arrow. And Max:bot goes toward the direction the arrow
indicates.
Please note: the “show arrow” function cannot be found directly in the
“Basic”. We should first click the “Basic”, there will then appears the “More”
under the “Basic”. Click the “More”, and you will find the “show arrow”
function. Place the “show arrow” function into the “on logo down”. Which
We need to use the “radio send string” function to send out the “Go” over
radio. Place the “radio send string” into the “on logo down”.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 81 / 101
Stop
Place both the “show arrow” and the “radio send string” functions into
the “on logo up”. Adjust the arrow pointing to the south and radio
Place both the “show arrow” and the “radio send string” functions into
the “on tilt left”. Adjust the arrow pointing to the west and radio send
the “Left”.
Place both the “show arrow” and the “radio send string” functions into
the “on tilt right”. Adjust the arrow pointing to the east and radio send
the “Right”.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 82 / 101
(5) By putting all above listed functions together, we will have the final
(1) Start a new project and name it as “sensing racing the receiving end”
(3) Here we need first to use the “servo write” to control the speed of the
wheels and realize the motions like: go forward, stop, turn left and turn
right.
Then, the “receivedstring” function and the operator “=” are used to
Combine all the function blocks listed below together, the final
racing game.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 84 / 101
Exercise
When playing a motion sensing racing, the larger angle your hands turn, the
larger angle the racing car on the screen turns. How to achieve this via
Max:bot, our reliable companion, has led us to escape the maze and win the
motion sensing racing. You may still have a sense of loss because Max:bot
never speak to you. But actually, he can even play the sound and light show!
Goals:
1. How to use the LED strip module?
Digital modules
Digital module(s) Image(s) Function(s)
frequencies.
Key information
Function Image(s) Function(s)
block(s)
” function can be
to be connected to
display.
of leds that
physically included
program
Program
(1) The function block for controlling the RGB light strip is not listed in the
tool box when we start a new project. To add this function, we need to
manually import the “Neopixel” from the bottom part of the page.
then select “Neopixel”. The Neopixel will show up in the function list.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 88 / 101
欢迎加入 DF 创客社区 www.DFRobot.com.cn 89 / 101
To start using the “Neopixel” function, we will first setup how many leds
are included in the light strip and which pin it connects to.
Then, use the “show rainbow” function to setup light effect. This effect
will only apply to leds that we defined in our last step. The parameter
inside the function block is used to set the gradient range of color, 1
represents red whereas 360 represents blue, the closer these two
The LED strip now can display the rainbow light effect.
Exercise
Connect two light strips separately to Pin5 and P11. Program the light strips as
below.
Can you tell us the differences between the two light strips? Record them and
·
·
·
Key information
Function Image(s) Function(s)
block(s)
in Makeode.
Program
(1) Start a new project and name it as “put the music on”
(2) Forever 中。The “start melody” function lies in the “Music” of the
(3) There are many melodies can be selected from the drop-dpwn list of
(4) In this part, we will use the “pause” function to provide enough time for
Max:bot to finish his song – the “dadadum”. Combine all the function
(5) Download it to Max:bot and you will hear his first song – the
“dadadum”.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 93 / 101
Exercise
What if you want Max:bot to sing a song composed by you? He can make
your dream come true. We will use the “play tone” function to set the tone
and beats.
As has shown in the diagram below that each tone corresponds to a certain
note.
By applying the “play tone” function, we can work together to edit the
Key information
Function Image(s) Function(s)
block(s)
executed.
Program
(1) Start a new project and name it as “the sound and light show”
(2) Use the “play tone” function to edit the “Jingle Bells”.
The first two phrases of “Jingle Bells” keep the same notes and beats. So we
professional.
following:
In this step, we will learn how to turn the two light strips into two “Fluid
LED Strips”.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 97 / 101
Before getting started, we should get to know what the Fluid LED Strip
is. It means the leds on the strip will be lighted up one by one until all
Find the “Make a Variable” from the “Variables” in the function area.
Place another “forever” loop from the “Basic” into the program area.
欢迎加入 DF 创客社区 www.DFRobot.com.cn 98 / 101
The pin P5 connected the left strip comes with 7 leds. To add a
rainbow light effect to the strip, we will need to set the color range
from 1-360 (red gradually changes to blue). The created variable “LED
The variable “LED Number” is used to determine how many leds on the
Since there are 7 leds on the strip, the number of variable “LED
a. When using the “set to” function, we should click the drop-down
b. If you are programming the left light strip, set the Pin as P5. Whereas
c. To realize the fluid light effect, we should place both the “clear”
(4) As we can see from above that the “Neopixel” function which controls
the light strip is used three time in the program. To simplify the major
loop, we can set a variable “left LED” to replace the long “Neopixel”
function.
Then place the long “Neopixel” to the right of the “set to” function.
the variable “left LED”. The “set to” function lies in the “Variables”.
Thus, we can apply the same procedure to program the right light strip.
By putting together all the functions listed above, the final program of
(5) Above we have learnt how to play the “Jingle Bells” and how to
display the fluid light effect. To enable Max:bot to perform the sound
and light show, we have to combine all the functions listed in both
Exercise
Since your Christmas robot is able to play a sound and light show, why not
asking him to go out and send presents for you?
www.dfrobot.com/blog