Computing With M Bot
Computing With M Bot
Computing With M Bot
https://www.makeblock.com
Contents
1. Introduction...................................................................... 9
6. lesson 1
Getting moving - getting the robot to move................. 27
7. lesson 2
Disco Time - Understanding inputs and outputs......... 37
8. lesson 3
Making me smile - further
understanding of input and outputs............................. 45
9. lesson 4
Sensing the world - an introduction to using
an ultrasonic sensor........................................................ 53
-5-
10. lesson 5
Moving all by yourself autonomus
movement using an ultrasonic sensor......................... 59
11. lesson 6
Don’t fall - understanding how to use a
line follower sensor....................................................... 65
12. lesson 7
Remote control - how to reprogram the controller... 71
-8-
INTRODUCTION
We’ve divided the book into 3 parts. The first part, Chapters 3 and 4, go
through how to set up the mBot and using this book in more detail respectively.
-9-
The second part, Chapters 5 to 12, consists of seven Lessons (Chapters 6 to
12) while Chapter 12 introduces some of the more advanced mBot functions.
All these chapters include UK National Curriculum links and are structured
in three parts: introduction, main task and plenary with an overview of each
Lesson in Chapter 5. The third and final part of the book (Chapters 14 to 22)
consists of the Challenges: activities to test and have fun with your newly
acquired robot skills.
In each of the Chapters we have included images, example codes and top
tips, where appropriate, to help you and make it as easy as possible to follow.
We have also included ideas how to extend each lesson and challenge. Once
you and your students are done with all our lessons and challenges, you can
come up with more challenges and activities of your own. We’re sure your
students will not be short of ideas! Remember that Makeblock robots are
modular: you can add extra bits such as six legs, servos and light and sound
packs or extra sensors which will open up a world of more fun, learning and
new possibilities.
Nicholas Hughes
-11-
Carlos Izsak
There are 2 types available to buy, Bluetooth and 2.4G. When you
buy an mBot you have to choose one of the types. What you choose will
depend on the hardware you have in school. The basic difference is how they
communicate with the devices you have in school.
-13-
Hardware Type of mBot
Mac 2.4G
Windows 2.4G
Chromebooks Bluetooth
Don’t worry if your hardware changes in the future as you can upgrade
the mBot to work with 2.4G or Bluetooth buy purchasing an extra part.
b. Assembly
So your boxes of robots have arrived, what’s next?
The mbots have to be built before you can actually use them in lessons.
Now it is up to you how you build them. You could build them each
yourself, or get your class to do it. Children in Year 5 and 6 are quite capable
of following the instructions in the box to assemble them. It will table about
45 minutes if they work in pairs.
-14-
You could build them as part of an initial lesson or get them built with a club
or perhaps your more able students. Once they are built, I would advise that you
keep them built. It makes things much easier when you want to use them again.
• Don’t worry too much about getting the motors plugged in the right
way round, when you test it, if it is incorrect it is a quick adjustment.
But the Left Motor plugs into M1 and the Right Motor plugs into M2.
• You may want to install the Bluetooth Module (a) or 2.4G Module (b) on
the mCore (c) board yourself you are worried about the children bending
the pins. It is the only delicate part of the build.
• It is important to plug the sensors into the correct ports on the mCore board.
Ultrasonic (d) plugs into Port 3 and Line Follower (e) plugs into Port 2.
-15-
• If you have the 2.4G version make sure you label the Wireless
Dongle (b) and the mBot. They are matched pairs, it is important
not to mix them up.
c. Testing
Now once they are build we need to test them.
You can control the mBot straight away using the included IR Remote
Control. It functions like a TV remote so you have to point it in the direction
of the robot and push a button.
Firsty make sure you have installed the batteries in both the mBot and the
IR remote, they are not included. The mBot takes four AA batteries and the
controller takes a CR2015 battery.
When you turn on the mBot it will make a few tones and the LED will be
white. The mBot will be in IR Control Mode.
-16-
Try pushing some of the buttons. If when you push forwards and it moves
backwards, you need to swap over the two motor wires which are plugged the
mCore board (c). Retest to make sure it moves as you expect. You can test the
Sensors by pushing the B and C buttons.
If you push B, the LED will go green and will move around and avoid
obstacles. If this doesn’t work correctly check the Ultrasonic (d) is plugged
into Port 3.
If you push C, the LED will go blue. Place your mBot on the line-follower
(e) map and watch it follow the line. If this doesn’t work correctly check the
Line Follower plugged into Port 2.
If you wanted to use the mBot with younger children using the IR Remote
Control would be an ideal way to do it. The mBot will function just like a
remote control car.
-17-
Hardware Type of mBot
mBlock App from App and
Tablets (iPad or Android)
Google Play stores.
Mac mBlock 3
Windows mBlock 3
Chromebooks mBlock App from chrome store
At the time of this writing mBlock 5 is still in beta testing. This is based
on Scratch 3, which will be fully released in Jan 2019.
The software that you install on Mac and Windows looks almost identical
to MIT Scratch. If you have used scratch before you will notice a few small
differences but it functions in exactly the same way.
The “Stage” to
hold drawings and
moving pictures (we
call those pictures Switch between different
“Sprites”) types of command blocks
-18-
You drag blocks to the right of the screen and they can be snapped
together like Lego bricks to create a program. The blocks relating to the mBot
are under a new set of blocks called Robots.
Now if you have bought the 2.4G Version of the mBot keep reading. If you
have bought the Bluetooth Version of the mBot skip down to the next section.
i. 2.4G Version
Most schools will choose to buy this version as it is the one recommended
for education, assuming that you aren’t using tablets or chromebooks. Make
sure you label the Wireless Dongle (b) and the mBot. They are matched pairs,
it is important not to mix them up.
In order to use the mBot with the programming software, mBlock, the
firmware on the mBot needs to be updated. Doing this makes the IR Remote
Control no longer work.
-19-
It is possible to do this in the initial lesson, but I would advise that it
is done before the first lesson.
To update the Firmware firstly open the mBlock software. Then using the
USB cable provided connect the mBot into the computer. The computer will
detect, the first time you do this, that something has been plugged in. Let it
install any drivers it needs to.
Then click on Connect, click on Serial Port and then click on COMXX,
the number will vary. If there is more than one option, unplug the mBot and
see which Port vanishes. Plug it back in and the choose that one.
If you ever want to reset the mBot to how it functioned out of the box,
plug in the mBot again, connect to it using the Serial Port and then choose
Reset Default Program.
Now when you turn on the mBot it will make one tone, this is telling you
that it is set up to be used with the mBlock software.
-20-
Once the mBots are built and have had their Firmware upgrade, take
all the remote controls, screwdrivers, USB cables and spares and store
them somewhere safe. You won’t need them for most lessons, but will at
some point.
If you are using mBot with tablets or chromebooks, then you will need
the Bluetooth version of the mBot.
In order to program the mBot, all you to do is to connect the mBot via
Bluetooth. No firmware needs upgrading. Within the app it will show you how
to connect to the mBot. You just need to make sure that Bluetooth is turned on.
Once the mBots are built take all the remote controls, screwdrivers, USB
cables and spares and store them somewhere safe. You won’t need them for
most lessons, but will at some point.
Top Tip:
When you turn on an mBot it makes a sound:
Dum, Dum, Dum = in starter mode.
Dum = in mBlock control mode
Take the wireless USB and label both it and the mBot, it is important that
you keep them together as matched pairs
-21-
how to use this book
The next part of the book will take you through a series of lessons to
teach the basics functions of the mBot to children.
Heading Explanation
-23-
Then it will break the lesson into 3 parts and go into series of detailed
step by step instructions.
With all of these lessons it is very important for you to have worked
though the lessons and activities before teaching them to the children. This
will increase your confidence in teaching it and also help you troubleshoot
any problems the children are having.
Each of the lessons are written to last around 45 minutes to an hour, this
will vary from class to class. You can and should adapt the lessons covering
less or more in each lesson as you see fit.
-24-
Overview of the Lessons
Lesson 1
Getting moving - getting the robot to move.
Overview: In this lesson we will be teaching them how to connect the
mBot, introducing the mBlock interface to the children and getting the robot
to move using the keyboard.
Lesson 2
Disco Time – understanding inputs and outputs.
Overview: In this lesson we will be learning about what inputs and
outputs are and programming the mBot to dance and sing using the buzzer.
Lesson 3
Making me smile - further understanding of input and outputs.
Overview: In this lesson we will be learning how to add and use the
LED matrix with the mBot. We will create an animated expression for
the mBot.
Lesson 4
Sensing the world – an introduction to using an ultrasonic sensor.
Overview: In this lesson we will be learning how to use the ultrasonic
sensor on the mBot. We will get the mBot to stop moving when it meets
an object.
-25-
Lesson 5
Moving all by yourself - autonomous movement using an ultrasonic
sensor.
Overview: In this lesson we will be developing our skills of using
the ultrasonic sensor. We will get the mBot to move around by itself
avoiding obstacles.
Lesson 6
Don’t fall – understanding a line follower sensor.
Overview: In this lesson we will be learning how to use the line following
sensor. We will apply knowledge we have gained in previous lessons to make
the mBot move around a table avoiding the edge.
Lesson 7
Remote control – how to reprogram the controller.
Overview: In this lesson we will learn how to program the mBot to
respond to the IR remote control.
lesson 1
Getting moving -
getting the robot to move
Overview:
In this lesson we will be teaching them how to connect the mBot,
introducing the mBlock interface to the children and getting the robot to
move using the keyboard.
NC Links
• Design, write and debug programs that accomplish specific goals,
including controlling or simulating physical systems; solve problems by
decomposing them into smaller parts
• Use logical reasoning to explain how some simple algorithms work and to
detect and correct errors in algorithms and programs
Lesson Objective
I can program the mBot to move using the keyboard.
Intro - 25 Minutes
(10 minutes - investigating precise instructions, 5 minutes - investigate
mBot, 10 minutes - how to connect to mBot).
-27-
Pose question to the class. What is a robot? Discuss children’s ideas.
They may initially give answers like R2D2 and WALL-E. Challenge them
to think about things that they see in the high street that are controlled by
programing.
Robot: From Czech, from robota ‘forced labour’. The term was
coined in K. Čapek’s play R.U.R ‘Rossum’s Universal Robots’ (1920).
(oxforddictionaries.com, 2017)
Ask for a volunteer. Explain that they are going to pretend to be to a robot,
they are going to perform a task, but have to follow the instructions the class gives
them exactly.
You will need to have decided beforehand what task they will be
performing considering what will work best in the space you have. You
could simply ask them to move to a place in the classroom. You could
ask them to move and pick something up such as a pen. The similar
the better.
Once the class is clear on what the ‘robot’ will be doing, ask them to
discuss in pairs what the instructions could be, they could note down what
they think on whiteboards or paper.
-28-
Walk forward ← For how long?
Turn right ← For how long?
Walk forward
Turn left
Walk forward
While the class are discussing this, talk to the volunteer and explain that
they have to do only what they are told. If something doesn’t make sense they
should do nothing or say, ‘Do not understand.’
For example if they are given the instructions turn left, they should just
just keep turning left. It may be helpful, if you have another adult in the room,
to ask them to be the robot first.
The class will give the instructions to the ‘robot’ and will have varied
success. Work as a class and edit the instructions so they are more successful.
What was important to remember when giving instructions? Agree that
in order for the ‘robot’ to move correctly you have to give clear, unambiguous
instructions.
Explain that you are going to program a robot called the mBot. Give a
mBot to each pair/group. Ask the children to look carefully at the mBot. What
do you notice? What sensors/capabilities do you think it has? Give them the
Wireless Dongle as well so the mBot and Dongle stay together.
-29-
Discuss what they notice, no detail is too small. Discuss as needed what
the parts are, sonic sensor, line follower, LEDs, motors etc...
Part Function
mCore is unfortunately under a cover but the children may be able to pick out
some details. You could try to open the cover so children can have a better look.
-30-
Part Function
RGB LED A light that be programmed to shine
different colours.
RJ45 Port Allows sensors to be plugged in, they are
uniquely numbered.
The “Stage” to
hold drawings and
moving pictures (we
call those pictures Switch between different
“Sprites”) types of command blocks
-31-
Firstly the children will need turn on their mBot, it should beep once.
If it doesn’t you will need to look back to page 19 and check they have been
set up correctly. There will be a flashing red light on the top of their mBot.
Then the children will need to plug their Wireless Dongle into the USB port
of their computer. Each mBot will have a paired Wireless Dongle, make sure
they are not muddled up. The red light that was flashing should stop flashing
when the Wireless Dongle has been plugged in. This shows that the mBot has
been connected to the computer.
You now need to connect the software to the mBot. Open up the mBlock
software, go to Connect and click, then move down to 2.4G Serial, click
on Connect. The heading at the top should change and say 2.4G Connected
instead of Disconnected. The mBot is now connected to the computer ready
to be programed.
-32-
Main Task - 25 minutes
Ask them to discuss what they think it will do? Take children’s responses.
Answer: The code makes the mBot move forward, it won’t stop though.
Ask children in pairs or small groups to use the dark orange and teal blocks to
create this code and find out what it does for certain.
After a while get children to explain what happens and why doesn’t it stop.
Answer: Because we haven’t told it to.
Ask children, Can they work out how to make the mBot stop? You
can show children the following code if needed. Most children will solve the
stopping problem with the solution to the right. They will tell the mBot to stop
when a key is pressed.
or
Set children a challenge. Can you program the mBot to move around
using keyboard inputs? Children will need to consider what keys they are
going to use, they need to make sure they have a way to stop the mBot moving.
-33-
Possible solutions:
The following examples are similar, the first example (Figure 16) just uses
key presses for events to happen.
The second example (Figure 17) is more advanced as it works more elegantly
using keys being released to stop the mBot moving. Both are valid solutions.
-34-
Extension
Make or mark out a simple track on the classroom floor. You could use
tape or just some books. Get the groups to test out their controls. Are they
accurate enough to get round the track? What changes could they make to
make the controls more precise.
Differentiation
• Less able children could be given a pre-prepared file with some of the
program already completed from them, for example the forward and
backwards keys are already done. All they would need to work out is how
to make it turn.
Plenary - 10 minutes
Gather groups together and review the challenge, did you program
the mBot to move around using keyboard inputs? Ask some groups to
share their solutions to the task. You can do this by moving round the
class or displaying their work on a screen or interactive whiteboard. Ask
groups to look at the programs being shared. What do they notice that is
similar and different? Answer: See examples above (Figures 16 and 17),
the children will use a range of different keys and methods to stop, note
that they all use the when key pressed event block Is there a best solution?
Answer: Easy to understand, no extra unneeded blocks. Is there a solution
that most of the class used?
-35-
Show children the following two sets of blocks. What do they do?
Explain that there is always more than one way to solve a problem, Which
of these is better? Depends what is important, the one on the left is easier to
understand. But the one to the left will allow adjustment of the motors on each
side so the mBot can travel in a straight line.
lesson 2
Disco Time - Understanding
inputs and outputs
Overview
In this lesson we will be learning about what inputs and outputs are and
to program the mBot to dance and sing using the buzzer.
NC Links
• Design, write and debug programs that accomplish specific goals,
including controlling or simulating physical systems; solve problems by
decomposing them into smaller parts
• Use sequence, selection, and repetition in programs; work with variables
and various forms of input and output
• Use logical reasoning to explain how some simple algorithms work and to
detect and correct errors in algorithms and programs
Lesson Objective
I can program the mBot to dance.
Intro - 15 minutes
Pose a question to the class. What is an input? Children to discuss what
they think. Take ideas from the children.
Explain that an input is when data is sent into a digital device. Can
you see anything on a computer that sends data inside it? Children may
mention keyboard, mice, webcam and microphone.
-37-
Pose another question to the class. What is an output? Children to
discuss what they think. Take ideas from the children.
Output is data that a digital device sends out. Again, can you see
anything on a computer that sends data out? Children may mention a
screen, speakers/headphones and printers.
Give out the mBots to the pairs/groups of children. On an mBot what are
the input and outputs? Give children some time to look back over the mBot
and try and identify inputs and outputs. Get them to feedback what they think.
Input Output
Children may not get all of these as some can’t be seen through
the mCore cover
On the board:
Ultrasonic Sensor LEDs
Buzzer
IR Transmitter
On the board:
Button
IR Receiver
Light Sensor
-38-
Ask the class, Where do the keyboard controls we used last week fit?
Are they an input or output? Why? Answer: Input because data is being sent
via the keyboard into the computer and then from the computer to the robot.
Answer: It makes the LEDs go red when the spacebar is pressed. Children
to discuss and explain what they think.
Give each group/pair an mBot and paired Wireless Dongle. Ask children
to make the code in mBlock and test their predictions. Children will need to
connect mBot to mBlock software before they can test their predictions. See
page 19 for instructions on how to connect the mBot to the mBlock software.
Where they correct?
The code makes the LEDs on the mBot go red, ask children to see
if they can get the mBot to show different colours. How many different
colours can they make? They will need to change the values in red,
green and blue. Move round the classroom encouraging children to keep
making new colours. Give some hints as needed: What happens if you
have a different number in each space? Can you type in a number?
What does changing ‘all’ do?
-39-
RGB Values
The LEDs are coloured according to RGB values. Using a mix of the
colours Red,not, Green and Blue other colours can be made. The values
range from 0 to 255.
(R, B, G)
Red (255, 0, 0)
White (255,255,255)
Purple (128,0,128)
Yellow (255,255,0)
Once all the children have made at least 4 different colours each, stop
everyone and show the following code. What does this do? Answer: When
the spacebar is pressed the LEDs will go red, wait 1 second then change to
green, wait for 1 second then change to blue. Children to discuss and predict
what the code will do.
Ask children to test their predictions by making the code in mBlock and
testing. Where they correct?
While the groups are testing, extend any quick finishers by asking them
to add a block that will allow the sequence to keep happening.
-40-
Once all the children have successfully made a simple 3 light sequence,
ask then what would I need to add to the code to make it repeat 10 times?
Children to discuss. Demonstrate adding in a report loop from the Control
blocks. So the code looks like the example below.
Ask children how can I keep the sequence going forever? Children to
discuss and give ideas. Demonstrate swapping out the repeat 10 times block
for a forever block from the Control blocks, as shown in the example below.
Now the children know how to flash the lights on the mBot.
-41-
The mBot will need to move on the spot and flash its LEDs in a light
sequence that has at least 6 different colours and repeats 10 times.
Choose a simple piece of music that the children will use. This site has
some nice royalty free tracks https://www.purple-planet.com/ though you can
use anything you wish.
-42-
Differentiation
• Less able children could be given a slightly different challenge of just
making the LEDs flash in a sequence. You could also reduce the number
of colours from 6 to 4.
This is in the Robots blocks and will allow the mBot to sing. In practice it
can be a bit quiet in a noisy classroom.
Plenary - 10 minutes.
Show the piece of code below. Ask the class, What is wrong with this
code? Can they predict what it will do? Answer: The LEDs will only go
red then blue, the LEDs won’t go green as it happens too fast for us to see,
because there is no wait after the change to green.
Ask the class, What where the inputs and outputs that we used in the
task? Answer: Inputs – Keyboard to program and start the dancing, Outputs
– LEDs, Motors, Buzzer.
-43-
Ask groups to share the mBots dance moves. You can technically get
all the mBots to ‘dance’ at the same time, but it is probably more practical to
choose a few groups at a time. Which dance is most convincing? If any group
makes the mBot move in an interesting way get them to share their code with
the class and explain it.
lesson 3
Making me smile - further
understanding of
input and outputs
Overview
In this lesson we will be learning how to add and use the LED matrix
with the mBot. We will create an animated expression for the mBot.
NC Links
• Design, write and debug programs that accomplish specific goals,
including controlling or simulating physical systems; solve problems by
decomposing them into smaller parts
• Use logical reasoning to explain how some simple algorithms work and to
detect and correct errors in algorithms and programs
Lesson Objective
I can program the mBot to display text or an image on the LED display.
Intro - 20 minutes
Ask the children to explain, What are the input and outputs on the mBot?
-45-
Input Output
Children may not get all of these as some can’t be seen through
the mCore cover
On the board:
LEDs
Ultrasonic Sensor Buzzer
IR Transmitter
On the board:
Button
IR Receiver
Light Sensor
Motor Spins.
-46-
Introduce the LED display to the class.
Explain that the LED display is an output device that we are going to add
to the mBot. (You may have decided to preinstall these before the lesson.) In
order to use the LED Matrix you need to swap out the Ultrasonic sensor.
Start by removing the two screws at the bottom of the Ultrasonic Sensor.
Unplug the cable from the rear of the Ultrasonic Sensor. Put the Ultrasonic
Sensor to one side. Take the LED Matrix and replug the cable into the back of
it. Then attach the LED Matrix using the same screws that you just removed.
The piece of plastic that is in front of the actual display is know as a diffuser.
The LEDs are very bright so it will cut down the brightness but also allows
images and text to display more clearly.
Explain that we are going create a program that will make the LED
Matrix display something.
-47-
Main - 25 minutes
Set class a challenge, can they make LED Matrix display some text,
number or perhaps a picture when they push a key on the keyboard?
Where will you be looking for the blocks? What clues will you be
looking for in the blocks? Get children to discuss and decide on some
keywords they will be looking for within the Robots section.
These are the only 4 blocks that relate to the LED Matrix.
The 1st one will display a short 3 characters piece of text. You can type
longer words but it won’t display it all. It does not scroll.
The 2nd one will display any number up to 9999, it can’t display any
larger numbers, if you try it will just display 9999.
The 4th one is the most useful and will allow you to draw a picture which
can be displayed. Click on the white rectangle and this box will appear. See
Figure 29 on the next page.
-48-
Figure 29. Image of LED Matrix Options from
drawing block.
Click on the lights that you want to turn on. You have some preset faces
you can use and you can Add to Favorite images you create. Click Complete
to store the image on the block. The white rectangle will have a tiny preview
of what should appear on the LED Matrix.
Give each group/pair an mBot and paired Wireless Dongle. Children will
need to connect mBot to mBlock software before they can can start the challenge.
See page 19 for instructions on how to connect the mBot to the mBlock software.
Remind children of the challenge. Can they make LED Matrix display some
text, number or perhaps a picture when they push a key on the keyboard?
As children work encourage them to try all the blocks but everyone
should spend the most time exploring the image creation block.
During the lessons ask children to share success with each other. Can
you tell everyone how you did a particular task?
-49-
Some possible solutions:
Figure 31. Image of possible solutions for using LED Matrix Blocks.
Possible solution:
Figure 32. Image of possible solution for creating animation using LED Matrix.
Children to continue to explore blocks and try and make a simple animation.
-50-
Differentiation
• Less able children could be given a saved file with all the necessary
blocks already dragged out. All they need to do it click them together and
then spend more time exploring how changing the values affects what is
displayed on the LED Matrix. For example:
Plenary - 5 minutes
Top Tips
If the LED matrix doesn’t work, check that you have it plugged into Port
3. This is the same Port that the Ultrasonic sensor was plugged into (Port 3).
Also remember to check the batteries the LED Matrix is very battery hungry.
The display also remembers the last instruction sent to it. So at the end of
lessons children should clear the display.
-51-
lesson 4
Sensing the world -
an introduction to using
an ultrasonic sensor
Overview
In this lesson we will be learning how to use the ultrasonic sensor on the
mBot. We will get the mBot to stop moving when it meets and object.
NC Links
• Design, write and debug programs that accomplish specific goals,
including controlling or simulating physical systems; solve problems by
decomposing them into smaller parts
• Use logical reasoning to explain how some simple algorithms work and to
detect and correct errors in algorithms and programs
Lesson Objective
I can program the mBot to stop when it reaches an obstacle.
Intro - 20 minutes
Ask the children to explain, What are the input sensors on the mBot?
-53-
A sensor that allows the mBot to
Follower Sensor recognise light and dark, so it can
follow a line.
A sensor that allows the mBot to sense
Ultrasonic Sensor if something is in front of it and how
far away it is.
Explain that we are going create a program that will stop the mBot when
it reaches a wall or obstacle.
Ask the class, What sensor do we need to use to make an mBot stop
moving when it reaches a wall/obstacle? Children to discuss and hopefully
suggest the Ultrasonic sensor.
-54-
The mBot moves forwards.
If the mBot gets close to a wall, the ultrasonic sensor will detect it.
The ultrasonic sensor tells the mBot to stop.
Explain that now we need the algorithm we have to turn it into code.
Show this code to the children. Want do you think it will do? Give
children time to discuss. Answer: The panda sprite will say the distance from
an object to the ultrasonic sensor.
3.200
While the children are discussing, you will need to connect the mBot to
the mBlock software before you can demonstrate the code. See page 19 for
instructions on how to connect the mBot to the mBlock software. Click on the
blocks to run the code, demonstrate the code working by moving your hand
towards and away from the ultrasonic sensor, the value will get smaller the
closer you hand is to the sensor.
Top Tip
If the sensor doesn’t seem to work, check the following. What port is the
sensor on the robot plugged into? Normally Ultrasonic sensor is plugged into
Port 3 and the Line Follower sensor is plugged into Port 2. Check on the block
what Port has been selected. They MUST match.
-55-
As a class create the following code linking back to the algorithm that
you created as a class.
Main - 25 minutes
Get children to copy the example code and programme their mBot to
move and stop as close as possible to a wall/obstacle. Get the groups/pairs to
consider some of the following questions. How close can you get the mBot
to stop? What is the fastest it can move and still detect an obstacle?
-56-
Differentiation
• Less able children could be given a file with all the code already
completed. They can then spend more time exploring how changing the
values to get the mBot stopping as close a possible to the obstacle.
• More able children could be encouraged to explore what could the
mBot do instead of just stopping when it is close to an obstacle. Could
the mBot be programmed to avoid the obstacle?
Plenary - 5 minutes
Ask groups to share what values were most successful? What did
you have to realise about the speed of the mBot? Discuss. Answer: Values
must be between 1-2. Any lower and the sensor isn’t accurate enough. Speed
has to be slow to allow the mBot time to realise it is close to an obstacle. Too
fast and it will hit the obstacle. The slowness is due to the time it takes for the
mBot to sense, send the value to the computer, be processed by the program,
and then send the right instruction back to the mBot.
Top Tips
• Obstacles need to be of a certain height to be detected. I have used books
and dictionaries in the past to make obstacles. Test the objects you are going
to use before the lesson. A nice idea is to create a wall round the edge of a
tabletop using books.
• The speed of the mBot needs to be kept quite slow as you need to give the
mBot time to process the sensor information and act on it. If it moves too
fast the mBot will stop after it hits the obstacle.
-57-
-58-
lesson 5
Moving all by yourself -
autonomus movement
using an ultrasonic sensor
Overview
In this lesson we will be developing our skills of using the ultrasonic
sensor. We will get the mBot to move around by itself avoiding obstacles.
NC Links
• Design, write and debug programs that accomplish specific goals,
including controlling or simulating physical systems; solve problems by
decomposing them into smaller parts
• Use logical reasoning to explain how some simple algorithms work and to
detect and correct errors in algorithms and programs
Lesson Objective
I can program the mBot to move around avoiding obstacles.
Intro - 20 minutes
Revisit last lessons work. Display the code below. Can you explain the
following code?
-59-
What was the task/problem that this code was designed to solve?
Can anyone remember the algorithm that was used to create this
code? Children to discuss and if possible get them to share what they
remember of last lessons algorithm.
This lesson’s problem is how to change this code to allow the mBot to
move around by itself avoiding obstacles.
-60-
Figure 37. Image of movement code
Activate the program by hitting the spacebar and demonstrate the mBot
moving around the area without hitting any of the walls.
Get children to discuss what they are seeing. What is the algorithm that
is being followed? It is similar to last weeks but with one important addition.
What do we need to add to our original algorithm to make the mBot do
more than stop? Answer: After stopping it reverses and then turns.
Discuss as a group and decide as a class what the new algorithm is.
Add highlighted section to last lessons algorithm. Display on a screen or
interactive whiteboard so class can refer to it.
Main - 30 minutes
-61-
The solution will be something like the example you used to demonstrate
how the mBot should behave on the previous page.
Please note: Each robot might turn different amounts, see the Top Tip at
the end of this chapter for more information.
Differentiation
• Less able children could be given a file with all the code already completed.
They can then explore changing the values of motor speed and wait times
to allow the mBot to turn correctly.
• More able children were asked to look at avoiding obstacles last lesson.
In order to further extend their learning ask, Should the mBot always
turn left? Can they randomise if the mBot turns left or right once it has
stopped? Below is a possible solution.
Figure 38. This code randomly picks a number when the ultraso-
nic sensor gets too close to an obstacle. Depending on the number
either the code that turns right is selected or the code that turns left.
-62-
Plenary - 10 minutes
Ask the class, What can we make the mBot do? Answer: make it move,
use the ultrasonic sensor, make it flash LEDs.
Input Output
Children may not get all of these as some can’t be seen through the mCore cover
On the board:
LEDs
Ultrasonic sensor
Buzzer
IR Transmitter
On the board:
Button
IR Receiver
Light Sensor
What do you think you can do with this sensor? Answer: detect a dark
line, detect an edge, it works by shining IR light and seeing what reflects, dark
colours absorb the IR light.
-63-
What do you think you can do with this sensor? Answer: detect a dark
line, detect an edge, it works by shining IR light and seeing what reflects, dark
colours absorb the IR light.
Top Tip
• You may find that each robot will turn different amounts. You cannot tell the
motors to move a set number of degrees as the motors are very simple. You can
just tell them to turn on and off for a set amount of time. One solution may not
work for all the mBots as the internal parts of the motor will differ as well as the
amount of charge in the batteries. To adjust the turn you will need to carefully
adjust the wait timer, generally you are looking for a value less than one second.
Remember, the wait command, allows the mBot to run the previous command
for a set time and then move onto the next instruction.
-64-
lesson 6
Don’t fall - understanding
how to use a line
follower sensor
Overview
In this lesson we will be learning how to use the line following sensor.
We will apply knowledge we have gained in previous lessons to make the
mBot move around a table avoiding the edge.
NC Links
• Design, write and debug programs that accomplish specific goals,
including controlling or simulating physical systems; solve problems by
decomposing them into smaller parts
• Use logical reasoning to explain how some simple algorithms work and to
detect and correct errors in algorithms and programs
Lesson Objective
I can program the mBot to detect the edge of a table.
Intro - 20 minutes
Explain that last lesson we discussed that an Line follower sensor can
detect an edge or a line.
Show the class this code.
-65-
Figure 40- Image of code
What do you think it will do? Relate it back to the example with the
ultrasonic sensor two lessons ago if needed. Children to discuss. Answer - the
panda will display a value, according to what the line follower detects. It will
be a number between 0, 1, 2 or 3.
Have a mBot connected to the mBlock software with the program ready
to run and demonstrate how this works. This can be done with a table edge or
a thick black line. With each mBot there is a poster that has a line on it which
can be used for line following activities.
Focus for now on making it detect an edge by both lights going out. Do
not use your hand as covering the whole sensor prevents them from detecting
anything, it will show nothing being detected.
You will notice that normally on the back of the line follower two red
LEDS are on.
Explain that today are going to make the mBot avoid the table edge. The
class will be using what they know about the ultrasonic sensor and making
the mBot avoid obstacles.
-66-
Why is the ultrasonic sensor not useful when detecting an edge? Answer
– ultrasonic sensors need something to bounce sound off, an edge has no surface.
Why do we need to use other sensors? Answer - Different sensors do different
jobs. Human use a range of senses to interact with the world, so do robots.
Ask the class, What is the algorithm that the mBot needs to follow?
What does the mBot need to do? Children can discuss in their groups and
record the algorithm for using a line follower sensor. You could display the
algorithm for the ultrasonic sensor as a starting point if they get stuck.
Get the groups to share their ideas and as a class agree on a shared
algorithm for the whole class to refer to, it should be something like this:
Ask the children, Does the behavior you have seen match be your
algorithm? Do you need to make any changes? Speed is one thing that children
may notice here, just like with the ultrasonic sensor, you have to be going slow
enough for the line-follower sensor to detect the edge and the code to react.
-67-
If the line follower
detecs anithing
stop and then turn.
Remember 3 is
the only value
that shows
that nothing is
detected.
Main - 30 minutes.
Set children off on the problem of program the mBot to move around the table,
but avoiding falling off the edge. Children should look at their code from the ultrasonic
sensor as a starting point. The solution will be something like the example above.
Top Tip
• You may find that each robot will turn different amounts. You cannot tell the
motors to move a set number of degrees as the motors are very simple. You can
just tell them to turn on and off for a set amount of time. One solution may not
work for all the mBots as the internal parts of the motor will differ as well as the
amount of charge in the batteries. To adjust the turn you will need to carefully
adjust the wait timer, generally you are looking for a value less than one second.
Remember, the wait command, allows the mBot to run the previous command for
a set time and then move onto the next instruction.
Differentiation
• Less able children could be given a file with the the simple ultrasonic sensor
from last lesson already completed. They can work how to adjust the code to
make it use the Line-follower sensor and make it stop at the edge of a table.
Figure 42. Image of incorrect code. Answer: You just need to swap the
ultrasonic sensor block for the line follower block and adjust the value to 3.
-68-
• Higher ability children could be encouraged to explore how they can they
use all the values from the line follower sensor to make the robot turn
more accurately? In the example if anything is detected on the line flower,
the mBot should stop and turn. This could make the mBot turn off the
table in some cases. If the sensor shows that the left side if off the table, it
should back up to the right to get away from the edge.
• Remember what the numbers mean:
• 0 = Both lights off. – Detects a line/edge.
• 1 = Left light off - Detects a line/edge to the left.
• 2 = Right light off - Detect a line/edge to the right.
• 3 = Both lights on. – Nothing detected.
A possible solution:
-69-
Plenary - 10 minutes
Ask the children, What have we over the last few weeks what we have
programed the mBot to do? Give children some time to discuss. Answer:
Made it avoid edges and objects, controlled it with a keyboard, etc…
Show image of The Curiosity rover. Does anyone know what this is?
Answer: a robot on mars.
Explain that this real robot needs to be able to ‘think’ for themselves. It
has to be able to transverse a wide range of terrain by itself, it can’t ask for
help from Earth as it takes far too long for instructions to be sent and received.
If you have time this video showcasing how teh robot moved across Mars
during its first 5 years is worth a look. http://youtu.be/O0nPFaBU98k
-70-
lesson 7
Remote control - how to
reprogram the controller
Overview
In this lesson we will learn how to program the mBot to respond to the
IR remote control.
NC Links
• Design, write and debug programs that accomplish specific goals,
including controlling or simulating physical systems; solve problems by
decomposing them into smaller parts
• Use logical reasoning to explain how some simple algorithms work and to
detect and correct errors in algorithms and programs
Lesson Objective
I can program the mBot to respond to the IR controller?
Intro - 10 minutes
Show children the IR controller. What do you think this is for? Children
to discuss.
-71-
Show the image below and explain that this shows what the controller
did when the mBot was first built. It doesn’t work anymore and we are going
to work out how to make the IR remote control to control the mBot again.
Give each pair/group a controller. Get them to discuss and record the
algorithm for making the controller work. What do they want to happen
when they push a button?
-72-
Some things they may not be sure about, Set Speed for example. This will
refer to the speed setting of the mBot. For now ignore the A, B and C button.
Get the children to share some ideas and make sure that all the groups
have an idea of how to start.
Show the following code. What does this do? Children to discuss and
give suggestions.
Answer: When you push the Up arrow on the controller it will start to
move forward. It won’t stop.
Main - 40 minutes
Give out mBots and Wireless Dongles to each group/pair. Get them to
connect the mBot to the mBlock software so they are ready to start.
-73-
This is a possible solution.
Differentiation
Less able children could be given a partly completed saved program.
They will have to complete it. For example:
-74-
• More able children could be encouraged to add in option for setting the
speed by using the numbered buttons. They will need to make a Variable
in the Data&Blocks Section. Call it Speed and then set the speed based on
what number you press from 0-9.
-75-
Advanced Functions
What this means is that things like voice recognition that take a lot of processing
power to do well, can be used on devices that wouldn’t normally be able to. It’s why
things like Siri, Google Voice and Cortana don’t work very well when your device
isn’t connected to the Internet, most of the hard work is happening off the device.
Using the Microsoft Cognitive Service the software can recognise what you
have said, or track faces and read text. This is at the moment still in the early
stages of being implemented but it does open up some interesting possibilities.
-77-
Figure 50. Image of Microsoft Cognitive Service blocks.
Under the Orange section on mBlock (and under its own dark purple tab
section in Scratch) you have a section where you can make your own blocks.
These blocks act like procedures. When you use the block it will always run
the program that has been set.
For example, I could make a block that is called Stop. This block would
be set up to stop all motors and end any running programs.
-78-
It is an important function as it allows you to simplify your programming,
by abstracting away details to make things easier to understand. Your program
will be easier to ‘read’
To create a block it is as simple as clicking ‘Make a Block’ and
giving it a name, for example green. A block appears called define green
and then below you add the program that you want to run when that block
is used.
These could be used to create movement blocks for forward, backwards,
left and right. See example below. So you could programme the mBot like
more simple robots such as a TTS Beebot.
Figure 51- Image of example BYOB (Build your own block) program.
About the challenges
The aim of these challenges is to practice and apply what’s been learned
in the lessons in a fun setting allowing children to experience and experiment
the different skills learnt whilst developing their computational thinking.
All challenges follow the format explained below. Please read carefully
and plan accordingly before attempting to do with a whole (or half) class,
and have all materials ready for each challenge. To perform challenges in a
normal lesson time can be a challenge in itself! Plan and try, the second time
you attempt the challenge it will be easier.
-81-
Each Challenges will follow this format:
Heading Explanation
Aim What is the challenge all about?
Materials Everything you need for the challenge.
Robot skills you need to complete the
Skills
challenge.
Then each challenge will be broken into 3 parts and go into series of
detailed step by step instructions.
Please feel free to adapt, modify, extend challenges at your will, you
know best your students and your school setting, be bold and brave and plan,
plan, plan.
-82-
Overview of challenges
Challenge 1
A-maze-ing: navigate through an obstacle course
Overview: In this challenge children need to navigate through a simple
maze in the shortest time controlling the mBot remotely using the keyboard.
Challenge 2
Pop: robot battle, can you pop your opponent’s balloon?
Overview: Each robot will be armed with a pin and have a balloon, each
pair of robots will battle to try and burst the opponents’ balloon with their pin.
Challenge 3
Sumo(ish) fun: push the other bot out of the sumo arena!
Overview: The aim of this challenge is to push the other mBot out of
the sumo arena before the end in three rounds; best of three wins the match!
Challenge 4
Robot football
Overview: In this challenge, teams of 3 or 5 robots compete to score the
most numbers of goals, winner gets through until 2 reach the Cup final.
Challenge 5
Art-bot: Drawing shapes
Overview: In this challenge, robots draw geometric shapes of equal size;
create an artwork with multiple shapes. Everyone’s a winner!
-83-
Challenge 6
Shake that (m)Bot dance competition
Overview: Whose got the best moves, program your robot to sing and
dance to the music with its own light show.
Challenge 7
Wakey Wakey Mr mBot
Overview: Program the best waking up routine for the mBot using
the light sensor, LED panel, sounds, movement and a light show. Who said
waking had to be boring?
Challenge 1: A-maze-ing!
Materials: Gaffer tape, stopwatch, 2x2 square meters of space (to set up
course).
Set up:
All children (or pair of children) should have an mBot that can be
controlled remotely using the computer keyboard. If no remote control
program has been set up or saved, this should be done first, check Lesson 1
for complete details how to do this.
Set the rules of the challenge before hand and set a time limit.
Beware of time, if working with a full class of 30, 15 mBots (one per
pair) and time limit for course of three minutes, it will take at least 45 minutes
to run. We recommend setting up two (or three, even four) exact courses and
running them at the same time, with the winner of each maze facing each
other in a grand final or choosing the overall shortest time as the winner.
-85-
Mark your maze on the floor using the tape, below is an example maze
drawing, where the side is approximately 1.5m by 2m wide:
You can try your own design, but keep it simple and test beforehand if
possible. Ask children to test their code before entering the arena.
OUT
IN
Figure 52. Example of a simple maze (tried and tested in the classroom)
Rules:
1. The robot that completes the maze in the shortest time wins. Create a
table with times so others can see the time to beat.
2. Mark how far each team gets on the course in case no pair can finish
the course so you can declare winner the mBot who came closest to the
maze exit (or second and third place).
3. Create a rule for when robots touch the line: one line touch and back
to start, three line touches and you’re out.
-86-
Top Tips:
• Tell class that their success depends mainly on two things: their code and the
driving controlling. Higher speed equals less control.
• If children when sitting at the computer do not have direct view of arena,
children can work in pairs: one child communicates to the other where to
go while the other controls the robot using the computer keyboard. This
encourages teamwork and communication! Make sure the drivers (the one
who controls the robot) cannot see the robot or maze so the competition is fair.
Ask group to keep excitement under control and noise level down so teams
can communicate.
• If enough time, try to let every pair have two goes. Encourage pairs to think
how they can improve for their second run, change code? Better driving?
Better communication?
Extension:
You can extend this challenge by:
Materials: Metal wire (garden or craft wire), pins, balloons, and tape.
Set up:
Robots will face off against each other in a non-destructive battle that
will test the driving skills of the operator and the manoeuvrability of the
robot. Robots will be armed with a pin on the end of a metal wire and must
use this pin to burst balloons attached to the other robot.
Test balloons and needles before hand: do the balloons burst too easily? Is
the pin sharp enough? How much do you need to inflate balloons? Make sure you
have plenty of spares and it might be a good idea to have inflated balloons ready.
This challenge is set in a square arena (like a boxing ring). The square
can be between 1.5 and 2.5 meters square (marked with a tape). You can build
or set up a short wall around the edge to prevent robots from leaving the arena.
-89-
Set up two arenas if possible so more battles can be run simultaneously.
Rules:
1. A wire will hold the balloon and a separate wire the needle.
3. The length of the wires, once attached to the mBot should be around 10cm.
4. The balloon and needle should be attached to the top of the wire,
needle at the front and the balloon at the back.
5. You can use tape, blue tack, or any other materials to attach the wire
to the mBot.
6. You are only allowed to re-attach the wire, if it falls off the robot, a
maximum of 3 times. The 4th time you’re OUT! Test before hand to
avoid disappointment.
7. Robots have to stay inside the arena, if it leaves the arena (completely)
three times you’re OUT.. A draw should be made at the beginning,
where mBots are chosen at random to face, each other in a cup style
format: winners stays for the next round, loser is out. For example,
If starting with 16 robots, there will 8 battles in the first round, then
a new draw is made after this round with the 8 winners until a final round. If
the number of robots is less than 16 or an number even you can use
this online tool: www.daftlogic.com/projects-cup-fixture-generator.
htm, simply enter the number of teams and their name and a full list
of fixtures will be generated for you. Max 3 minutess per battle, if
no winner after 3 minutes you can chose as winner the robot who
went out of the arena plus amount of times the wire had to be re-
attached the least number of times. Or flip a coin to decide the
winner. Remember time is at a premium. The winner is the first
robot to burst the other balloon!
-90-
Top Tips
• Make sure your wire is strong before the battle begins.
• Test balloon can burst by needle.
• Keep needles protected with a tape when not in battle to avoid any injuries
or accidents.
• Have two arenas at the same time, with a grand finale between the winners
of each arena.
• Keep an eye on time, it should take 10-15 mins to set up robots, 45mins to
1 hour of battle time, balloons will have to be re-attached after each round,
winners only! (if enough time and space you can let round losers battle each
in a separate arena)
• Warning: noise level during this activity can be very high due to over excited
children, think of ways how to manage behaviour using some of your usual
class management tools… good luck!
Extension:
You can extend this challenge by:
- Trying with self-driving mBots! It’s an interesting computing
thinking exercise to investigate how to program an mBot for this kind of
battle and contrast the program against a typical object avoidance self-drive
program. It is unlikely you will have time to try this so why not have a class
discussion at the end?
- Have battles with more than two bots at a time, even all the robots at
once! (You will need a bigger arena). Warning: Mayhem may ensue!
-91-
Challenge 3: Sumo(ish) fun:
push the other bot
out of the arena!
Set up:
This challenge is ideally set up in a circle arena with a radius between
1m and 1.5 m, in Japanese this is called the dohyo. It’s easier to mark a circle
with a chalk attached to a string, place one end of the string in the centre of
the circle and draw a circle. If not possible to draw a circle in your class or
somewhere in the school, use tape to mark a square as in previous challenge
(between 1.5m and 2.5m side).
Rules:
• Each match will consist of 3 rounds of 60 seconds each between 2 robots.
• If a robot leaves the arena or dohyo, the opposing robot wins the round.
-93-
• The first robot to win 2 rounds wins the match.
• If neither robot wins the round, the referee will choose the winner,
based on aggression, manoeuvrability and style.
• You’ll need to mark the starting lines (shikiri lines in Japanese),
mark or draw two parallel lines of 1cmx10cm (width and length)
centered in the ring and spaced 10 cm from each other as in
diagram below.
• The winner of each match will compete against winners of other
matches, until one robot is crowned the Grand Sumo Champion.
You can use a draw generator as in rule 8 of previous challenge.
Tawara
10 cm
Shikiri
Figure 54. Sumo ring (or dohyo). A 1 to 1.5 meter radius with
starting lines in red (shikiri) and border line (Tawara).
-94-
c. Both robots touch the exterior of the dohyo at the same
time.
d. Any other conditions under which the referee (or teacher)
judges that no winner can be decided.
Top Tips:
• You could run the competition in team with points awarded
per match. Team with the most points wins the competition.
• Tell students to move fast to have enough kinetic energy to
push the other robot. Moving fast also makes it harder for
the other bots to get you!
• Tell students to learn and accept the rules. It’s silly to get
disqualified because you didn’t pay attention to the rules. If
enough time, watch some sumo wrestling or robot sumo so
students familiarize themselves with the sumo battle rules.
Extension:
• Try to program the mBots to run autonomously. How can you program
them to find another bot and push it out of the arena? How can your
mBot avoid going out before finding the other mBot?
• Why not try a rumble? The rumble is a single sumo match with up to 16
different robots to determine which robot can remain on the dohyo after
-95-
all the other robots have been pushed off the ring. The rumble could be
played on a larger dohyo and the time limit could be set to 5 minutes or until
there is only one robot left inside the arena. At the start, each robot must
be a minimum of one robot diameter away from its nearest competitor.
Materials: Tape, ball (ping pong or golf size), whistle, measuring tape,
card, lollipop sticks.
Setup:
A 3 or 5 a side football match is played between two teams. Each team
consists of three or five robots, one of which must be the goalkeeper, more
robots can be added to sit ‘on the bench’. Each robot must be clearly labelled
and numbered in case the referee needs to identify them during the match.
The goalkeeper must be designated before the match starts. A match may
not start or continue unless both teams have at least one functional robot.
• Each of the two teams has a color assigned, stick a piece of coloured
card with their player number on top of the mBot.
• Control hooks: robots can be fitted with an extension to allow greater
control of the ball. Attach a pair lollipop sticks to ends of the mBot
front. Have a quick practice before the match. Make sure hooks are
securely in place.
-97-
• Protection: we recommend protecting robots with foam or other
protective material (such as bubble wrap) around the chassis, specially
on corners, to avoid long term damage to mBots
• Best playing surface is hard floor, felt mat or short carpet. The playing
surface must be level, flat, and hard.
• Set up of a pitch (or two). Suggested dimensions of pitch: 9m long by
6m wide for 5 a side or 4.5m long by 3m wide for 3 a side.
• Goals must be placed on the centre of each goal boundary and
anchored securely to the field Surface. 1m wide for 5 a side and 0.5
m wide for 3 a side size field. You can use any static object for this.
The inner part of the goal can be covered with an energy absorbing
material such as foam to help absorb ball impacts and lessen the
speed of deflections.
• Ball: use a ping pong, golf or similar size ball.
Rules:
• The match lasts two equal periods of 10 minutes, unless otherwise
mutually agreed between the referee (teacher) and the two participating
teams. Any agreement to alter the periods of play (for example, to
reduce each half to 7 minutes because of a limited schedule) must be
made before the start of play.
-98-
• Teams are entitled to an interval at half time. The half-time interval
must not exceed 2 minutes. During this time teams can adjust robots,
code and discuss tactics.
• No Offside rule.
• Robots may be interchanged (with those on the ‘bench’). There is
no limit on the number of interchanges. Removal of robots from the
game can only be made during a stoppage in play, the referee must
be informed before the proposed interchange is made, a robot enters
the field of play after the robot being replaced has been removed. The
robot enters the field of play at the halfway line.
• Any of the robots may change places with the goalkeeper but this
must notified to the referee (and other team).
• A robot can be sent off if (a) is guilty of unsporting behaviour (b) is
guilty of serious and violent contact or (c) persistently infringes the
Laws of the Game.
• Referee: a referee will officiate the game, if no referee is available
teams have to agree decisions. The referee has full authority to enforce
the Laws of the Game in connection with the match. If no referee is
appointed all decisions have to be agreed between the two teams. If
no decision can be agreed between teams, teacher will be called to
make ultimate decision and this will be final, no TV replays or video
refereeing!
• The winner if each match goes to the next in a cup style competition.
Make a draw as in challenge 2.
• A coin is tossed before each match and the team which wins the toss
decides which goal it will attack in the first half of the match. The
other team takes the kick-off to start the match. The team that wins
the toss takes the kick-off to start the second half of the match. In
the second half of the match the teams change ends and attack the
opposite goals.
• At the beggining of each half, each robot is located at least partially
in its own half of the field. The opponents of the team taking the kick-
off are at least 50cm from the ball until the ball is in play. The ball is
stationary on the centre mark. The referee gives a signal or blows the
-99-
whistle for the team taking the kick-off, one robot is allowed to leave
its own half of the field, as long as this robot stays within the center
circle and no other robot touches the ball. The ball is in play when is
‘kicked’ and moves. The kicker does not touch the ball a second time
until it has touched another robot. Game on!
Top Tips:
• “In football everything is complicated by the presence of the
opposite team” (Jean-Paul Sartre) encourage teams to come up with
tactics to score goals and disrupt (within the rules) the opposite
team.
• The best way to gain an advantage over an opposing team is to
know its strengths and weaknesses, as well as being able to predict
its behavior. How can a team learn all this information? By a
process known as “scouting.” Scouting consists of watching the
matches of the other competitors and recording the key information
about their behavior.
• Good communication between team members is essential to perform
well. Get teams to choose a captain and work together as a team!
• Check the mBots screws are tight and secure before each match.
Ask students to think about their code, is it better to have a fast
mBot (less control) than a slower one? What is the ‘sweet spot’ or
best setting between speed and control?
• Before every match, make sure that batteries are fully charged and
fastened securely.
Extension:
• Play a league! You can set up a robot football lunchtime league with
keen players. Keep the field marked for ease of setting up.
• Tactics are key in team sports, the more they play the better they will
get at it. If your students are really enjoying playing robot football,
try to find times for them to practice and play. Why not use golden
time for this?
-100-
Did you know? RoboCup who organize yearly world tournaments
state in their official site (http://www.robocup.org/objective)
that the ultimate goal of the project is:
Aim: Program the mBot to draw shapes on the floor and create robot art.
Materials: Marker pens, Tape, Paper (big format e.g. flip chart/A0).
Skills: Children should be able to code a square, rectangle, triangle and other
geometric shapes in scratch. If they cannot this will need to be looked at first.
Set up:
• Attach a marker pen to your mBot and set the mBot on the floor, make
sure pen is securely attach and is not too low (too much friction) or
too too high (not enough pressure), you’ll be able to test this when
the mBot starts drawing.
-103-
• Ask children to work out how to draw a square.
• They might want to start by just drawing a line (of a set length) and
making a turn (of 90 degrees)
a. Try this code and use a ruler or tape measure to see how far your
mBot travels.
b. Now you’ll have an idea of how far it will move in 1 second. Adjusting
the time time will change the distance. A lot can affect this though
such as, friction between pen and paper, how much battery your
mBot has, efficiency of the motors, etc. Note that distance travelled
could be different for each bot!
a. Try this code and use a protractor to see how far your mBot turns
-104-
b. Now you’ll have an idea of how much the mBot will turn in one
second. Ideally a 90 degree turn is what you want. In practice it will be a
turn of somewhere been 0.5 and 1.5 seconds. A lot can affect this though
such as, friction between pen and paper, how much battery your mBot has,
efficiency of the motors, etc. Note that distance turned could be different
for each bot!
• Now, using the information gathered above, for line length and angle of
turn, the code form drawing a square should look something like the one
on image below where L is the length of the desired square and T is the
amount of time to turn a 90 degree angle.
• Now, think about how to draw rectangle and triangles and if you have
enough time other geometric shapes, start with regular polygons! Please
refer to the top tips section for instructions how to do this on screen first
if you prefer.
-105-
We propose the following format to run a competition if you wish, you
could run the activity freely as well i.e. just let the children tinker and play
and see what art masterpiece they come up with!
Art competition rules:
Have fun!
Please Note:
It is useful (but not necessary) to be able to code in Makeblock, or Scratch, how
to draw a geometric shape first. It’s very important to notice that you’ll need to
make a few changes to any code you have used with the screen turtle or sprite as
the mBot differs quite a lot from the due to mechanical differences (e.g. battery
life, assembly, motors etc). Before children can create a program for the mBot, to
draw geometric shapes they need to work out how to make it travel a set distance
and make an accurate turn. The mBot cannot move forward or turn a set distance
due mainly to basic motors. Instead of a code with a specific line length or angle,
you need to find the right amount of time to move for the mBot to be able to draw
a shape. The move block needs to be substituted by the block run forward, but
how far do we need it to move? We’ll need to set a time limit, this will vary with
each robot, so the children will have to try different settings.
-106-
If using the repeat function, it will look something like this.
-107-
Top Tips:
• Give yourself plenty of practice time to practice at your own pace
before attempting this activity with a class group if at all possible.
The more time you spend and understand how to create interesting
shapes and patterns, the more fun you (and your group) will have.
• Try drawing screen shapes first so children get familiar with the
robot turtle concept and develop their computational thinking
skills. Below is an example code to draw a square. How would
you code a rectangle? what about a triangle?
• Code for drawing a square on screen should look should look
something like this (when not using repeat function):
Extension:
What other shapes can you make? Can you combine the shapes? Can you
use more than 1 pen? Can you program the mbot to draw patterns?
What if you make a generic program that will draw any regular side
shape? What inputs would you need? Do you need to set up a variable?
Challenge 6:
Shake that bot!
Dance competition
Aim: Program your robot to sing and dance to music with its own
choreography and light show.
Set up:
You can perform in groups or individually. When we say individually
we mean the robots, a robot might be used by two or three children at the
same time.
Firstly, choose a song that is upbeat and fun, with a simple structure, pop
and catchy. Something like Uptown Funk by Mark Ronson should work!
You could let each robot have a different song but bear in mind the noise
and complexity this will add to the challenge.
Get students to think first what kind of choreography they’d like first,
let them brainstorm and plan some ideas on paper before allowing them to
code. Once they start coding it gets technical and more challenging to get
-109-
students to think at a higher level i.e. what is that they are trying to achieve
with their code?
You can also let children decorate and dress the mBot for the occasion,
let them be as creative as possible!
Once children, have planned a dance routine, get them to start coding
it. A dance routine could consists if steps, a step be something like move
-110-
forward half a second, move backwards half a second, turn around, move to
the left, move to the right. You can then put together a routine by combining
steps. An easy way to think about the whole routine is to have a step for the
intro, one for the verse of the song, one for the chorus and one step for the end
(a twirl is always a good way to end!).
Remind students to add lights to their moves, one way would be to have
distinctive light for each step in a routine, this could be static or dynamic.
For instance, the intro could be red, first verse blue and flashing white for the
chorus! You can even add notes to emphasize changes between parts, try to
match the tunes tone!
Rules:
Similarly to the previous challenge, this challenge is more subjective
to judge and similarly we can use the same criteria as in the artbot
challenge.
-111-
• The winning piece will be the one with the highest score.
• A special prize can be given to the pieces with highest creativity and
best composition as well.
Top Tips:
- Allow plenty of time for children to plan their routine and then
implement it. They might realise that some dance moves require
complex programming, they can revise their plan and adapt it to
make sure they complete the challenge in the allocated time.
- Encourage children to be creative and inventive, watch some dance
choreographies videos of your choice at the beginning of the session
for inspiration.
- Check that you’ll be able to play the video in your classroom
computer beforehand, for instance check that youtube content is not
blocked by your school system in advance.
- Get groups of children to try how best to synchronize their mBot
start with the song, this could be done manually by starting the code
and song at the same time, the easiest way to done this would be to
program the robot to start the routine when the space bar is pressed,
load the song on youtube (or other similar platform) and start the
song with the space bar. Voila! Instant synchronicity!
- Get a disco ball for extra disco glitz!
Extension:
One way to extend this challenge would be to group robots in teams
and get them to perform a song as a group, not all robots in a group have
to perform the exact same routine but a level of similarity and synchronous
dance will be expected.
You could let children to choose their own song instead having the same
song for all, the song will have to be approved by teacher (check video is age
appropriate).
Challenge 7:
Wakey Wakey Mr. mBot
Materials: Large room ideally with dimmable lights and/or blackout curtains.
Set up:
This is more of a programming challenge and most of the activity will be
spend programming and testing the code. Note that, in this challenge we use
the mBot on board light sensor, so for this you will need to be in a room where
you can control the light level either by turning lights off or dimming them or
by closing curtains or a combination of both. You’ll need plenty of space for all
mBots as part of the fun will be to have all robots performing at the same time.
Step 2: Create ‘emotions’ using LED panel. For instance, create a ‘face’
fo when robot is ‘sleeping’ i.e. when there is no or little light and another
‘face’ for when robot is awake. For example, when your robot is asleep you
could try some sleepy eyes using the show drawing block:
-113-
Figure 62. Example of mBot eyes closed or ‘sleeping’ eyes.
You’ll also need an awake face also using the show drawing block, for
instance:
Now we’ll use the on board light sensor as an ‘If then else’ block (from
the Control block group). The main idea here is to use a conditional block to
specify two types of behaviours depending on the light level. One behaviour
for low light level, is the ‘sleeping’ behaviour which you can keep quite simple.
While the other behaviour, for higher light levels, will be more complex by
combining different ways of making the mBot move, make sounds, change its
‘face’ and using the on board LED’s.
-114-
Note that you will need to adjust the value of the light level in the if block
depending on your own setting. The light sensor on board has values from 0
(no light) to 1023 (full light) so it’s a good idea to start with a value round the
middle, for example 600.
An example code, using the faces above, a value of 600 for the change of
behaviour and getting the mBot to ‘blink’ once it wakes up, would look like this:
Image 64. Example code for programming ‘sleeping’ while lights are off (or light
less than 600) and ‘blinking’ when then lights are on (or over a value of 600)
How many times does it blink? Is the time between open and closed eyes
too long, too short or about right? How can we make it more interesting?
(some possible answers to these questions are fund in the next steps).
-115-
Just adding some code for the onboard LED lights would look something like:
Image 65. Using the on board LED to add the ‘sleeping’ and ‘awake’ estates.
We can then add more behaviour, for instance, lets add some movement
after blinking, such as moving left, then right, forward and back. Such code
would look like this:
-116-
Now, we can add some sounds, for instance:
Finally, in Lesson 3 we mentioned that the LED screen can only display
a short text and it does not scroll. However, we can make text scroll in the
LED panel by using some coding!
Note that the show face block has x and y coordinates and that they are
set to 0 and 0 as default. If we make the x value change after a set time, we can
make text scroll. In order to do this we need to create a new variable. Click
on the orange ‘Data & Blocks’ menu , then select ‘Make a Variable’ and call it
‘X’. This will be the position of the text, to make the text scroll to the left we
need to change the position by -1 and wait a short period of time (for example
0.2 secs) and repeat until all text is displayed.
An example code to display a message such as: “Hello time to get up”
would look like:
Image 68. Example code for scrolling text. Note that you’ll need to
create a new variable ‘X’ if your text is longer than 3 characters.
-117-
So, now you can put all of the above code, or your own, in order in the else
section of the If else block. Be careful with the order and aware that you might
need to add pauses (wait blocks) between certain parts. Test your code first
without the conditional to make it easier to debug before putting it all together.
Once all students have finished and tested their code, turn the robots off,
turn the lights off, turn the robots back on, press the green flag on the mBlock
software (or whatever key you have used to activate your code) and watch!
Rules:
Similarly to the art-bot and dance challenges, this challenge is subjective
to judge and we can use the same criteria as before or just simple let the
children have fun and do it as a group challenge. Get all mBots ready, turn the
lights on (or off) and have fun!
Top Tips:
- Allow plenty of time for children to plan their waking up routine and then
to implement it as before. They might want to use some previous code and
add to it.
- Try different values for the light sensor and find one that works best on your
context. Start with 600 and if too low and the robot only shows its ‘awake’
behaviour, make it higher. Conversely, if the robot stays in its ‘sleeping’
behaviour try a higher number and see what happens.
- Be careful when adding the on board LED lights in the sleeping part of the
code, if too bright they might trigger the on board light sensor. Use a small
value, remember that values go from 0 to 255.
- Remember to use Port 3 in the show face and other blocks that use the LED
matrix.
- Get students to create their routine in secret and do reveal all at the same
time when turning the lights on.
Extension:
You can set a more detailed design brief for the sleeping and awake
behaviours. For instance, can you make a snoring noise while asleep? Or set a
different routine in which mBot wakes up, blinks first then moves, then show
a smiley face, then make some noise while moving and turning lights off.
-118-
Try adding the LED matrix without taking out the ultrasonic distance
sensor, in that case connect the Matrix to Port 4 and make sure you use that
port on the corresponding blocks (show face, show time, show drawing). Can
you code a distance measuring display?
You can program the opposite behaviour i.e. a simple behaviour for when
the lights are on and a more complex behaviour for when the lights are off
(or below a certain level), so instead of going to sleep the mBot does a crazy
dance when the lights go off.
You could ask students to create different emotions for the robot once
it wakes up using the show drawing block and add colours (using on board
LEDs) to each emotion.
Try using the LED matrix and the line following infrared sensor. Can
you program it so you know when zero, one or the two sensors are on to
display something accordingly?
Other MakeBlock
Products
mBot itself is just the first level of a series of customisable robot kits.
They also offer:
-121-
The kit can be used to create 3 different styles of robot, the control board
also has more built in sensors and a capacity to add more input and output
devices. It is programmable on a computer or tablet and supports block based
programming.
The kit comes with instructions for 10 different designs and can be used
to build more personalized creations. The control board is more advanced
again and can be used to drive a wide range of servos and motors. It is also
compatible with Raspberry Pi and Arduino. It is programmable on a computer
or tablet and supports visual or block based programming, Python, Arduino
IDE and other programming languages.
-122-
They also produce the following:
CodeyRocky - https://www.makeblock.com/steam-kits/codey-rocky
Is their newest robot that combines a small handheld ‘brain’ with a tracked
body. The handheld section has a LED screen and a range of sensors. Then
it is plugged into the tracked body it gains a extra sensor and the ability to
move. Think of the brain like an advanced micro:bit. It is programmable on a
computer or tablet and supports both block based programming and Python.
-123-
Age Range: KS2
- https://www.makeblock.com/steam-kits/neuron
Is a series of blocks that can be joined together via magnets and then
programmed using a computer or tablet. You have a range of different input and
output blocks that will allow you to build all wide range of contractions. If you
have ever seen littleBits or SAM Labs it is in the same vein. It is programmable
on a computer or tablet and uses a block based programming langage.
-124-
Age Range - KS2 and above.
Airblock - https://www.makeblock.com/steam-kits/airblock
https://en.wikipedia.org/wiki/Turtle_(robot)