Mbotandme
Mbotandme
An informative guide for both the young and the not so young !
An explanation of everything mBot; including how to use the mBlock 5 programming
interface, full details of useful add-on components and the best ways to modify your
new robot.
An in-depth guide
for both the young
and the not so young !
Windows 10 / mBlock 5
2020 Edition
For Emma
… a Scientist ?
… a Gymnast ?
… an Engineer ?
… a Dancer ?
… an Astronaut ?
Whatever she does, I will be a proud Grandad (and it’s been a privilege).
"Don't let your past dictate who you are; but let it be part of who you will become".
also dedicated to
John Coll
John Coll was asked by the BBC to help draw up the functional description for a computer which
could be used as part of a television series to teach computer literacy. - Quote: "It was John’s drive,
determination and sheer brilliance that really pulled the whole thing off".
Contents
Chapter 1 An Introduction (… or how it all began …) ......................................... 1
Appendix 6 mBot ‘add-on’ Component - Six Legged Robot Pack ................. 219
Appendix 10 mBot ‘add-on’ Component - Light & Sound Pack ...................... 231
Appendix 11 mBot & Mblock 5 - All you need to know about LEDs ................ 233
Appendix 12 mBot Light & Sound Project - Robot ‘Light-Chasing’ ................. 239
Appendix 13 mBot Light & Sound Project - ‘Intelligent Desk Light’ ................. 243
Appendix 14 mBot Light & Sound Project - Robot ‘Scorpion’ .......................... 253
It also said on the front of the little booklet inside the top of the box that it was ‘mBot - One Robot per
Child’ for beginners to learn STEM (Science, Technology, Engineering & Mathematics) - so was this
really a present for me? Emma’s mum (my daughter) explained quickly that this was for me to show
Emma how to build & modify the robot and how to programme it” … it works on Scratch you know”
and “… its Arduino you know!”. “… Arduino - is that a fundamental particle of nuclear physics?” - I
was now out of my depth, I hadn’t a clue.
Had she thought to herself - Emma’s mum, that is - “That’ll keep the old fossil’s
(or something ruder perhaps?) brain working…”?
Keeping the old-boy's brain overloaded more like! Well, it is my seventieth birthday this year.
I had heard of Scratch and knew that it was a graphical programming interface for kids using coloured
blocks that fit together like a sequential jigsaw, but I had never used it and had considered it to be a bit
too simple. I wondered how much mBot had cost them? Ball-park figure in the UK about £85 I guess.
So, with the festivities in full swing & lunch imminent, I had to put the box to one side. Eventually, in a
lull in late afternoon, Emma and I ‘unboxed’ it (that’s a fashionable consumer word isn’t it). The
processor board and the chassis were in full view at the top of the box in a very neat cardboard tray. We
lifted it out and examined the contents - it was all beautifully made. In the bottom of the box was
another cardboard divided tray with all the other bits. Little brown plastic bags that contained
mysterious circuit boards which we left untouched, bags of screws & nuts, cables & the wheels. Emma
found the Screwdriver (she’s so practical) and had whipped-off the wrapping before I could blink and
was exclaiming about it being double ended “… it’s like an Allan key shape” she said meaning the
hexagonal cross-section. She studied all the bits that were unpacked and tea-time approaching, I
promised her that we (she, I mean) would build it soon - but not today.
Well, the next time we would meet to do that would be just over a week later - her first day back at
school after the Christmas holiday which coincided with the day of the week we normally go to visit.
That gave me time to study all about it - ‘that’ll be a breeze’ I thought!
On the day after Boxing Day I started my researches on the great world-wide inter-web and immediately
saw that there was a lot more to this mBot and Scratch programming than I thought. I found several
rather informative videos on YouTube and marked one of them showing the build-sequence with a
bookmark to show Emma before we (she) started our own construction. I found out a lot about
Makeblock who manufacture & market mBot too and I had a go at tentatively trying to slot some
programming blocks together on the mBlock programming interface which I had to download from
Makeblock. I also downloaded it to my Surface tablet PC so that I could communicate with mBot via
Bluetooth.
My observations and all the projects in this book are based on me using Windows 10 PCs - but they
should mostly (I hope) apply to the other operating systems on which mBlock works.
A book on mBlock was what was I needed - so I looked; and there was plenty to be found
on Scratch but almost nothing specific to mBlock or mBot written in English. There seemed
to be paperbacks in German and Dutch and several non-English hardback versions together
with a newly published (USA, Dec. 2017) ‘Kindle’ format book. But nothing that seemed to
explain ‘everything Makeblock’.
What I wanted (and seemed to be writing) was a fully-explained, complete and sequential
understanding of everything about mBot (and how programming in mBlock works). The
title ‘mBot & Me’ probably should have been ‘mBot, Emma and Me’ but since I seemed to
be doing all the work and ‘Me’ is the prefix for Makeblock’s Me series modules (it’s an
abbreviation of ‘Makeblock electronics’); this play on the word ‘Me’ seemed to fit the bill.
A busy week passed in which I decided to visit PC world and buy one of those little dongle gizmos that
you plug in to a USB port to communicate by Bluetooth - this was for my desktop PC which hadn’t (as
most don’t) an integral Bluetooth
connection as standard. A little poorer by
£13, I got home to test it by linking my
mobile phone to the desktop via Bluetooth.
A week later we collected Emma from
school, and I showed her the little video on
my Surface tablet. She seemed very
enthusiastic, so we set about undoing all
the bags from the box and laying out all
the bits on her dining table. Between us,
we followed the instruction diagrams in
the little book and Emma inserted screws
in to all the right places.
She had already built Lego models on her own (by following pictorial guides) and setting to work on
mBot’s out-of-the-box construction, she used her lovely new screw-driver very competently.
We connected it with the serial cable to my Surface tablet and I showed her what I had learned about
putting robotics blocks together to make a little programme that did indeed communicate with the robot.
Since I had not yet had the chance to buy a battery for the IR remote, we couldn’t test that & by tea-time
she had had enough.
The following week, we had another go. She was lively to start with but was tiring quickly after another
long day. The highlight was the IR remote and the three default modes of mBot operation. She loved
steering it around the house and making mBot chase the cat. She thought that line-following on the little
figure-of-eight track was brilliant too. I thought to myself however that the task I had been set by my
daughter was going to take a long time…
… We are nevertheless making (me in particular) good progress and we have had a few technical hitches
so far, but nothing that someone reasonably competent can’t work around. These are often genuine
robotics issues that robot builders will always encounter at some point. All the problems we have had
have been a learning experience (for me) rather than a distraction. As is often the case with computing,
you learn more when stuff goes wrong, and you must fix it or find another way around it.
There are lots of robot toys out there that claim to be truly programmable when they really mean they
can be controlled from a remote or an app. and mBot is indeed programmable. Many educational
(supposedly programmable) robots are quite restricted in what they can do. Whereas mBot is
fantastically capable by comparison - and cheaper. With mBot you can design custom robot models that
react to sensors, move, play sounds and update lights; and especially if you add the easily available and
not too expensive add-on packs like the LED Matrix Display Plate (see Appendix 1, page 184) you can
develop useful feedback systems.
mBot is essentially a children's robot, but it's part of the Makeblock family of beautifully made robotics
kits and components for hobbyists (see the image below). You can progress on to Arduino
programming with mBot. Teenagers (and Granddads, one hopes!) will be able to move onto other
robotics products in the Makeblock range and build projects such as a 3D printer, a robot arm, a drawing
machine or a robot of their own design, although much of this stuff is expensive.
Makeblock is described as a leading Chinese technology and robotics construction company providing a
platform for makers, DIY hobbyists and educators. They raised funds in a ‘Kickstarter’ crowd-funding
campaign about five years ago to establish one of the company’s most popular products - the mBot kit.
They have developed Arduino based hardware, robotics hardware, and Scratch based software,
providing educational tools (using robotics) for learning programming, engineering, and mathematics.
Their robotic kits work with mBlock (a variant of Scratch), a programming language that lets users
easily control their robots’ movements by using programming software which is made up of pre-loaded
colourful and modularized drag-and-drop graphical blocks. Using it, children feel that they can easily
programme mBot without writing difficult code or using textual programming language.
Although the company first started out creating robot parts for the do-it-yourself ‘Maker’ community
Makeblock has since shifted its focus to Science, Technology, Engineering and Mathematics ‘STEM‘
educational robots with the belief that it is essential to encourage creativity and innovation in the
younger generations.
There are two versions of the mBot, a Bluetooth version for home use and a 2.4 GHz Wi-Fi version
designed for classroom use.
Everything that you need to build it is in the neatly packaged box and you need to assemble it using the
precise instructions provided and then add your own batteries. There are 45 pieces and it's easy to put
them together in about 15 minutes. Once you put everything together, mBot can move around and avoid
obstacles on its own, follow a line or just accept commands from the supplied IR remote control.
With the Makeblock app for phones and tablets you can control mBot via Bluetooth. For children
especially, it can be a surreal experience to actually build something out of tiny parts and see it come to
'life'.
mBot is designed to be tinkered with, and the idea behind Makeblock’s mBlock programming interface
is that younger children can start out with graphical programming and move on to text-based
programming as they become more advanced. This is what they hope will inspire the next generation of
engineers. Makeblock Me Series Modules (their plug-and-play electronics circuit board components)
are designed to be simple to connect and easy to programme and each Me module comes with its own
Arduino library for easy programming.
Makeblock aims to help children build robots and learn to write computer programmes in a fun and
educational way as the trend for incorporating coding (the latest educational buzz-word) and robotics
into education becomes desirable. The company believes that their kits will help users develop logical
thinking and gain the mindset and thought-processes of a programmer - although their systems are not
just for aspiring programmers.
About Scratch
Kids from 7 or 8 years old and upwards (inc. their grandparents!) can learn to write simple programmes
for mBot using Makeblock's very intuitively simple to use software mBlock 5 (a variant of Scratch 3)
and using this free mBlock software is simplicity itself and causes no problems with the majority of
computer operating systems.
Scratch is both a programming language and an online community where people can programme and
share interactive media such as stories, games, and animation with others from all over the world.
Scratch is designed and maintained by the Lifelong Kindergarten group at the MIT Media Lab.
Massachusetts Institute of Technology Media Lab came into being in 1980 with the aim to invent and
then reinvent how humans experience and can be aided by technology. Their current Scratch software is
provided free of charge and can be downloaded from:
https://scratch.mit.edu/download
While Scratch is primarily designed for 8 to 16-year olds, it is also used by people of all ages, including
younger children (with some help from their parents, grandparents or teachers). The current version
available to download is Scratch 3.0 and I would recommend downloading it as a learning counterpoint
to mBlock 5. It generally has much better help features and has an excellent ‘Wiki’ (a website on which
users collaboratively modify content and structure). This can be accessed from:
https://scratch.mit.edu/search/projects?q=wiki
As children create with Scratch, they learn to think creatively, work collaboratively, and reason
systematically. They can programme their own interactive stories, games, and animations by moving
small pictures called ‘Sprites’ on top of a backdrop called a ‘Stage’.
Learning Scratch is a good and a VERY easy way to understand many programming concepts, but as an
ICT teacher I personally achieved many of its goals by teaching kids by using instead the universally
used Microsoft Office multi-application environment.
I used to use ‘PowerPoint’ to develop logical sequencing skills (this was such a good introduction to
programming things) followed by using ‘Visual Basic’ (Microsoft’s own powerful Macro programming
language) which has a slightly different variant inside each component of ‘Office’. My favourite
component for this was ‘Excel’ where high-quality user interfaces could be developed.
My granddaughter had already done some simple block programming of interactive stories using
Scratch Junior (designed for kids aged 5-7, using touch-screen tablets) on an iPad at her primary school
and she loved it too! The first time we opened mBlock, I was impressed when she showed me how to
colour in a background for the stage.
Earlier Scratch and mBlock environments were written in Adobe Systems ‘Flash’ and based on open-
source software. Importantly, neither Scratch 3 nor mBlock 5 now no longer require Flash to be
installed to run. mBlock 5 works very well and Makeblock provide a very helpful support service and
an excellent forum where you can interact with other users as well as their own ‘Technical Support
Department’.
It’s worth pointing out that the Scratch community also provides tons of help with general scripting (but
not robotics scripts) problems.
You will find that programming problems can be a learning experience rather than a distraction and, as
is often the case with computing, you learn more when stuff goes wrong, and you must fix it or find
another way to solve a problem.
About Arduino
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino
hardware boards are relatively inexpensive compared to other microcontroller platforms and Arduino
software is easy-to-use for beginners, yet flexible enough for advanced users. It runs on Mac, Windows,
and Linux platforms.
Arduino consists of both a physical programmable circuit board (often referred to as a microcontroller)
and a piece of software, or IDE (‘Integrated Development Environment’) that runs on your computer. In
earlier versions of mBlock software, this Arduino programming software was installed automatically on
your PC (as a separate entity) when you download mBlock.
In the latest (totally rewritten) version of mBlock (mBlock 5) there is now an Arduino Editor built-in
with one-click switching between graphical programming Scratch blocks and ‘Arduino’ code. mBlock 5
has a built in editor for programming in ‘Python’ code too.
Arduino came to prominence as a tool to help designers, artists, and musicians access the power of
inexpensive 8-bit microcontrollers by learning 'a little programming' without having to acquire the full
range of skills needed to work with embedded electronics. mBot has an ‘approved’ Arduino derived and
enhanced board (mCore) at its heart. The Makeblock mBot is highly regarded and although it is fairly
expensive in its own right, it is considered to be the most widely available and one of the cheapest robot
kits, with hundreds of thousands distributed around the world.
Arduino based boards (remember, mCore is one of these) don’t have an operating system per se, so
whatever is loaded into the board’s flash memory is what will be run at power-on. It is therefore
possible to compile code and substitute your own programme for mBot’s default code by ‘uploading’ it
into mBot.
To enable mBot to interactively communicate with the mBlock 5 software, you need (as updates become
available) to upload to its mCore board the latest upgrade of special ‘firmware’ which interacts with
mBlock at low level allowing you to access the Arduino board features interactively from the graphical
programming environment. If mBot’s flash memory is overwritten by your own customized code, and
you want to clear this code, then you will need to do a firmware upgrade, and also upgrade mBlock 5’s
software with the latest available version - see Chapter 9 (page 37) for more on this.
Kids get a sense of achievement from building the robot, and it goes together quickly so they won't get
impatient. The mBot chassis is made from anodised aluminium - it's beautiful and feels solid and of
very high quality.
The sensors and motors connect
easily to the board, with no fiddly
clips, jumper leads or breadboard to
worry about. The board has high-
quality RJ25 sockets which receive
push-in connectors. These ports are
clearly labelled, and colour coded
which is important when it comes to
programming them later.
mBlock 5 is essentially a visual software development system; but at the outset, only when the mBlock 5
software on your PC and the mCore board on mBot are connected to each other by either cable,
Bluetooth or wireless can you control your robot.
Changing the colours of the onboard mCore LEDs using mBlock 5 is a simple and fun activity to get
started. mBot has a small buzzer capable of playing musical notes too. Since I learned to programme
Clive Sinclair’s ‘Spectrum’ in the early 1980’s, programming pitch changes for mBots piezo buzzer
gave me a sense of déjà vu (and probably will too for everyone old enough to remember it!). The
ultrasonic (proximity / distance) sensor can be used for detecting things that come too close. For a
novice programmer it’s fairly exciting; and experimenting with feedback from it is fairly easy.
Buying add-on components, as soon as you feel able too is a good idea and I would recommend the LED
matrix digital display as your first add-on since it opens-up many opportunities for simple but very
effective programming by drawing images to display or setting a scrolling message or count-down
timers. See Appendix 1 (page 184) for more on this. Emma particularly enjoyed using the ‘immediate
feedback’ potential of LED panel graphics.
It is reasonably easy to get many of things such as the LED panel working with a bit of help from items
posted on the very, very useful MakeBlock forum which can be found at:
http://forum.makeblock.com/c/makeblock-products/mbot.
mBot comes with default (Factory Setting) firmware which responds to a small infrared remote-control
handset which is included in the box. This means that once you have sorted out power, connections and
firmware updates you can immediately play with mBot as a remote-controlled toy. It took about four
weeks before we spotted that the IR remote had a removable protective film around the buttons!
The infrared remote is immediately usable from the box to control mBot, but it is also programmable via
mBlock 5 which is fantastic since you can create your own key-press instructions.
This means you can control the robot with your own commands via the remote control even when it's
not physically connected to a computer. This was a very popular initial programming activity for us,
and Emma loved being able (eventually) to write very simple scripts for the IR remote to make mBot do
what she wanted.
You should be aware that the IR remote control will control any mBots in range - this can be fun for
coordinating several mBots, but not such fun when two kids want to play with their own mBot in the
same room. See Chapter 7 (page 28) for more details on the IR remote.
Electric motors like those that power mBot are often mismatched, very slightly, (which is a common
problem in robotics). This can make the IR control steering experience less than perfect;, and you can
with a little experimentation set one to run marginally slower than the other to achieve a straight track
e.g.:
It is also possible to run the drive motors individually in mBlock 5 using the following extension block:
Beware though, full re-programming of the button controls is rather more complex and only works when
your scripts are uploaded to the flash memory of mCore, the Arduino board which is mBot’s brain.
Despite what I said when mentioning add-on packs earlier, there's much that you can do with the basic
mBot so there's not really any need to buy anything extra to start with. There's plenty of
experimentation to be had with your own scripts to keep you busy, but it's good to know that you can
extend the robot for not much extra outlay when you need something new to try. Being part of the
MakeBlock family, it means that there are quite a lot of extra components that can be used to upgrade
mBot, enabling you to build new projects. The basic add-on kits are easily resourced in the UK but
many other (desirable but expensive) components are not.
Programming mBot will probably inspire you to learn more, enabling you to link robotics with complex
programming of sprite output on the stage too.
Many other toys and kits that are available may be brilliant for a few hours or perhaps a few weeks and
then kids have done everything there is to do with them, but mBot is not really like that at all. Many
young users have been completely inspired to design their own robots and then are inspired enough to be
constantly planning and working on their own fantastic ideas
The box that mBot comes in can be opened without destroying it and it is sturdy enough to use to store
your assembled mBot.
If you remove the inner packaging then your completed mBot robot fits nicely in the box with space for
the IR remote, the cables, spares, tools etc. It might sound trivial, but it's a nicely thought-out and well-
designed touch from Makeblock. Parents be thankful - it’s always hard to keep track of cables, spares
and add-ons for techie toys - but not in this case!
I started this way too, but as you’ll see a little later (in Chapter 17, page 156) that I eventually needed to,
and did, succumb to bigger and then even bigger storage options.
Basically, and with a few provisos, mBot a is indeed a very impressive piece of kit.
All of Makeblock’s products (not just mBot) are of the highest quality and are so well finished and
packaged! mBot is a perfectly affordable robot for techie families where an adult can give a bit of help
to get children started. mBot is also perfect for schools or robotics clubs with specialist teachers.
Emma whizzed through the basic learning package on her tablet. For any child, writing simple scripts to
programme colour-changing lights is fantastic, as is programming mBot to move around with their own
commands. Then they've got the light sensor, the ultrasonic sensor and the line-follower to explore; let
alone the ability to play (sometimes annoyingly repetitive) musical notes through the on-board buzzer.
And that's before you even consider the such good value add-ons such as the aforementioned 8 x 16
LED matrix display panel pack and the Servo add-on pack which can extend what you can do with mBot
in so many more ways …
After about ten weeks of experimenting with mBlock (v.5.0.1) in the early part of the year, what was
apparent was that there was little clear, detailed and succinct guidance to this major application update.
In the second part of the year after another version update, nothing has changed. You have to search the
internet and indeed Makeblock’s own support pages very hard to find anything of value to familiarise
yourself with mBlock 5. Even the helpful 'User Guide', accessed from the ‘Tutorials’ icon on the right
of the mBlock 5 title bar (in the form of an HTML file provided by 'GitHub'), does not give you a fully
descriptive or clear overview of the nuances of how mBlock 5 should be used. Despite some limitations
it is nevertheless such a useful reference that I bookmarked this page in my web browser to be able to
access it directly without having to open mBlock 5 first.
N.B. You can find the ‘GitBook Quick Start Guide and FAQs’ using the following internet link:
http://www.mblock.cc/doc/en/
I do like what I have seen of mBlock 5 so far and despite some minor, but I hope constructive,
criticisms noted in this book I am looking forward to using future improved releases. I am looking
forward too, to the release of more mobile devices variants of the software; since the majority of
Android (Intel x86 chip) systems (including my very new Galaxy Note 9 phone) are not yet supported!
mBlock 5 has been specifically designed by Makeblock to support their robotics products and is based
on Scratch 3 and Arduino code. Supported robots are ‘mBot’, ‘mBot Ranger’ and ‘Codey Rocket’
together with their ‘HaloCode’ board and their ‘Neuron’ app. There is also support for the programming
of several Arduino boards including the versatile ‘Uno’ board and the BBC micro-bit (micro:bit) too.
mBlock 5 is available for desktop Windows PCs and mac OS platforms and there is also an mBlock 5
Mobile App which currently runs on Apple iOS 9.0 (and above) devices together with Android 5 and
above devices (but currently, Arm-based chips only). Makeblock say that the Mobile App integrates
concepts of programming into different and increasingly difficult game levels to keep interest in coding
going by unlocking new programming skills step-by-step.
Some of the graphical improvements featured in mBlock 5 (and the equally new Scratch 3) are a great
improvement; especially the one which shows a ‘shadow’ indicating that blocks are within range to
connect to each other when connecting and disconnecting them. The shadow feature is again used rather
nicely when blocks are dragged back over the categories pane to delete them; and greatly improved too,
is the ‘illumination’ of the user-defined content windows within blocks which indicate that ‘nesting’
another block inside that window is imminent.
There has been much hype about the virtues of mBlock 5 as a programming tool which is versatile and
user-friendly enough to offer users whatever the latest iterations of the parent Scratch application can
give. Scratch 3 (developed by MIT) is the latest evolution of Scratch which is one of the most popular
computer programming languages for children in the world. It is available in more than 40 languages
and users can create, share and mix projects on many different hardware platforms. For help with
programming using mBlock 5 there are several (mostly created in mBlock 3) ‘how-to’ videos available
on ‘YouTube’, and the on-line mBlock community allows users to share projects and learn from like-
minded creative individuals.
Makeblock says that mBlock 5 provides both graphical (block-based) and textual programming
languages within the software and their aim is to deliver the best in STEM / STEAM education in coding
and robotics. Although mBlock 5 is fundamentally for robotics programming, with this software users
can drag programming blocks about in the same way as in its parent application (Scratch) to design and
create stories, games and animations and all without needing any additionally connected hardware. The
raison d'être of mBlock 5 is to enable users to programme hardware devices; the Makeblock family of
robots, the BBC micro-bit (micro:bit) and the very popular Arduino Uno board using either drag ‘n drop
block programming or (with increasing skill levels) textual programming languages.
Whilst the novice programmer can experiment fairly comfortably using drag n’ drop blocks, they
certainly can’t try to write Arduino code in the editor and Python whilst being easier and clearer to
understand than Arduino is not that simple and mBlock 5, critically, gives no actual guidance on how to
use either of these editors (although the ‘GitBook Quick Start Guide’ does have a good basic
introduction to Python).
The transition for any adventurous user into studying or using ‘real’ programming code is now fairly
seamless; and it is possible to see either ‘Python’ code as a comparison to any ‘Sprites’ tab scripts
created or ‘Arduino C’ code as a comparison of ‘Devices’ tab scripts. In either, the code can be copied
to the clipboard and pasted into the respective editor for experimentation.
The new paint and sound editors offered in both Scratch 3 and mBlock 5 make it easier to manipulate
characters, music, and sounds. It is now possible in both applications to detect and interact with motion
and sound with the video-sensing features of a web-cam; whilst the sound editor has been redesigned so
that it is even easier to record sounds and many new sound effects manipulation filters (‘faster’,
‘slower’, ‘echo’ etc.) have been added.
mBlock 5 comes with a cloud storage service too which is specially designed for A.I. (Artificial
Intelligence) and IoT (The Internet of Things). Makeblock state that these features allow users to
master the fundamentals of some of the latest cutting-edge technologies. It also integrates Google’s
deep learning library of open educational resources for problem-solving using A.I. and ‘Cognitive
Services’ - an evolving portfolio of machine learning algorithms for building intelligent applications by
adding features such as understanding spoken and written language together with facial, speech and
human emotions recognition.
Once you come to realise that mBlock 5 has in reality two different Scratch programming sections to use
(with mostly different blocks in each of them) it is easy to see where you are going to create ‘Device’
scripts that control mBot and ‘Sprite’ programming scripts that can be used to animate realistic graphics.
Understanding how ‘Broadcast’ messages can be used to transfer data-on-demand between the two to
enable you to display sensor feedback from mBot visually on mBlock’s ‘Stage’ or clicking meaningful
sprites to send control commands back to mBot is vital. By using your own graphics to create high-
quality interfaces, feedback data from mBot can be represented in a variety of real-time digital, analogue
or alphanumeric output formats; and representations of switches etc. can provide real-time controls for
mBot too! (See page 75 and Chapter 13 for more on this).
The user interface (the ‘Edit’ page) is an improvement on the January (v.5.0.1 release). The ‘Scripts’
area is larger and there are now just two choices to adjust the script area size (& therefore the stage size
& sprites list size too).
Both the ‘Edit’ page and the full-screen ‘Presentation-Mode’ display seem to be sharper brighter &
clearer. Sadly perhaps, the ‘Presentation-Mode’ surround screen is no longer dimmed down (to nearly
black) as it was in mBlock 3 and it is now only slightly dimmed; which does have the advantage of
seeing a looping script ‘pulse’ etc. - but that is not really a lot of use and for the most part is actually
intrusive since it detracts from the contents on the presentation screen itself. If the surroundings were
totally black then this would be so MUCH better.
Projects still do not remember which of the three variable monitor windows types were last active when
they are reloaded in any new software session. They do remember that they were set to show on the
stage and where they were positioned, but they always revert back to the default ‘labelled’ monitor type.
A great improvement though is the much needed addition of an ‘Export’ sprites facility enabling
reuse of the sprite, its block coding and any costumes attached to that sprite in other projects.
Attached (or floating) comments remain attached to exported sprites too.
Right-click on a sprite (or the device in the ‘Devices’ tab) and ‘Export’ becomes an available choice.
This saves a single sprite as a .sprite3 file. These can be added into another project by using the
‘Upload’ button in the sprites library. A sprite containing block scripts uploaded this way is NOT
however added into your ‘My Sprites’ library. A ‘Devices’ tab device icon can also be exported, and if
uploaded then the resultant .sprite3 file will open as a new device in the ‘Devices’ tab of a project
remembering both device type and any attachments - this seems to be a very quick way to start a new
project with some useful device stuff already in place!
It is now possible too to export a .png image of all of the coding blocks written for any sprite by right-
clicking on the ‘Scripts’ area for that sprite (or device) and choosing ‘export all scripts to image’.
A sad loss from the ‘Menu’ bar is the button giving instant access to ‘My Projects’. To choose a project
you now (rather more slowly) have to select ‘Open’ from the ‘File’ menu to access the ‘My Projects’
screen - it is slower, but it’s OK though (when you get used to it!).
Usefully, ‘Regularly Used Devices’ can be set to appear each time you open a
‘New’ project.
To make mBot your default start-up device, open the ‘Device Library’. In the
top left corner of all device icons in the ‘Device Library’ list is a hollow star.
Click the hollow star inside the mBot icon and it will turn solid blue.
Existing extensions have had several updates over the last year and several new extension packs have
been added too, namely: Data Chart, Google Sheet, Translation, Speech, Motion Sensing, User Cloud
Broadcast and Upload Mode Broadcast.
However, most of the extension packs (both those for ‘Devices’ and those for ‘Sprites’) seem to be of
rather limited use! Makeblock have now unlocked the ‘Extension Center’ too to enable users to create
their own extension block sets. I have yet to try this.
In the parent application (MIT Scratch) you are restricted to and constrained by the ‘graphical jigsaw’
(block-based) options provided and there has in the past been some criticism of Scratch as an
introductory programming language due to its drag-and-drop visual style; suggesting that it gives
children (its target audience) the wrong idea of programming and it being watered-down compared to
other programming languages such as C++, C, Java or JavaScript.
The new mBlock 5 variant of Scratch 3 now addresses this supposed lack of showing ‘real’
programming language syntax in its parent application by allowing users to easily switch to either the
‘Arduino’ editor (for ‘Devices’) or the ‘Python’ editor (for ‘Sprites’) with just one mouse-click - see
Chapter 5 (page 19) for more on this.
mBlock’s much vaunted concept is to enable users to grasp how to programme with blocks first, and
then “effortlessly move on” to seeing how their programme looks using text based coding. mBlock
promotional material makes much of this one-click switching to ‘Python’ but rather disappointingly,
there seems to be no mention that ‘Arduino C’ is the language required to programme connected robotics
devices.
Whilst the novice programmer can experiment fairly comfortably using drag n’ drop blocks, they
certainly can’t try to write Arduino code in the editor and Python whilst being easier and clearer to
understand than Arduino is not that simple.
mBlock 5, critically, gives no actual guidance on how to use either of these editors (although the
‘GitBook Quick Start Guide’ does have a good basic introduction to coding using Python to programme
sprites).
Makeblock tell me that their company support focus is on their own official software (mBlock 5)
and they say that they are not prepared to give much guidance to programming in Python or
Arduino, suggesting that users should learn to use these languages by themselves.
The new Scratch 3 application has the stage positioned on the right of the interface; but I guess that the
stage remaining on the left in mBlock 5 has the advantages of the interface still allowing any compiled
programming language code to be shown in a pull-out window from the right of the screen; just as it
always did.
It noticeably takes about four times longer to start-up mBlock 5 than its forerunner, mBlock 3. On my
current computer, mBlock 5 loads in about 12 secs as opposed to 3 secs for mBlock 3. On the plus side
though, everything inside the new software works much quicker and more seamlessly than it did before;
and it is indeed a great improvement on its predecessors!
The user interface (the ‘Edit Page’) now has brighter colours and they are indeed sharper brighter &
clearer than they were before. Just compare the title / menu bar screenshots below.
The top image of the two screenshots below is of July’s release of v5.1.0 whilst the January release (v
5.0.1) is shown below that. It is obvious from this comparison that the latest version of mBlock 5 is
indeed much more vibrant and professional looking, with a colour scheme which echoes the Windows
operating system’s default colours.
The remainder of the interface is remarkably similar to its updated Scratch 3.0 parent. The newly
designed ‘Blocks Area’ panel of colour-coded category buttons is positioned to the right of the stage and
towards the centre (depending on the size of your screen) of the edit page. Next to that is a sub-panel
area showing the list of currently selected blocks and on the right of the screen and dynamically
expanding to fill the remaining part of the interface is the ‘Scripts’ (block programming) area.
On the extreme left of the title bar in the January release (v 5.0.1) there was a ‘Main Menu’ icon and
clicking this gave you the options of creating a new project, opening a project from the computer,
accessing help and exiting the application, etc. However, in the bright and shiny July release (v 5.1.0)
this has been removed and these important menu items are now grouped under the ‘File’ menu heading
(the third icon across the title bar. In my eyes this is a retrograde step and the ‘Open’ option takes just a
little longer to get to the thumbnail based ‘My Projects’ management page. You create a new blank
project page by just clicking the (+) icon here. Sadly, the icon taking you straight to the same
management page of your ’My Projects’ files (stored in the Cloud) is no longer part of the new title bar -
another retrograde step!
To the left of the ‘File’ icon is the ‘World’ icon and here you can switch to one of thirteen languages for
the interface if you need to (a good way to learn some technical French perhaps?). Although mBlock 5
sensibly identifies your computer system’s default language when it installs itself.
The new ‘Edit’ icon to the right of the ‘File’ icon is rather limited - it just seems to turn ‘Turbo-Mode’,
used to speed-up (fast forward) running scripts for stage presentations either on or off. Next in the title
bar at the top of the interface is the default label ‘Untitled’, this is the ‘Title’ icon. Click on this to
change (rename) the title of your current project.
Immediately to the right of the title icon is the ‘Save’ (‘Floppy Disk’) icon. Click here to save a file
directly to your ‘My Projects’ cloud storage area. This is useful for fast saving when working on a
project. There are no other save options here so you have to return to the ‘File’ menu to find the option
‘Save to your computer’ - using this is important because it enables you can store your files into a
purposely structured and hierarchical folder system of your own. Making sequential backup copies of
your files to both ’My Projects’ in the mBlock cloud AND to your computer is not a bad idea either.
I would advise against clicking the rather prominent ‘Publish’ icon in the centre of the title bar (for now
anyway until you make a specific decision to share your work with others). As soon as you click the
icon it will save the project that you currently have open on your screen to the cloud and then open a
dialogue (note the screenshot of this below) enabling you to make your work available to the mBlock
community.
Fortunately, your work is only published and made available to everyone in the community if you click
the ‘Share’ button at the bottom of the dialogue. If you do this then be aware that other community
users will now be able to use the file or ‘remix’ it as a version of their own. Towards the right of the
title bar is the ‘Tutorials’ icon and this is now where the ‘Example Programs’ management page can be
found.
The examples page enables you to access a variety of samples for ‘Device’ and ‘Stage’ programming.
There have been some improvements to the stuff available, but the example robotics programmes
currently available seem to be just for the 'Codey Rocket' robot and the ‘HaloCode’ single-board
computer. Makeblock really should provide sample programmes for mBot users here too.
Use the ‘Feedback’ icon on the right-hand end of the title bar if you think that you have something
important to impart to Makeblock. Response is fast and I think that it is one of Makeblock’s great
strengths that they have a courteous and knowledgeable team in support of their hardware and software -
but you have to be very clear, precise and succinct in what you are trying to tell them. The icon to
the right of the ‘Feedback’ icon on the title bar allows you to check for updates.
The ‘Sign-In’ icon at the right-hand end of the title bar looks like it ought to contain your picture.
mBlock 5 keeps you ‘Signed-In’ to the mBlock cloud (even if you close down the application itself)
until you ‘Sign-Out’ again. It is now possible to modify some of your account details in your profile and
to change your nickname etc. (but not your picture). This icon also gives you access to the mBlock
cloud storage service which is a very fast & efficient way of saving / reloading project files; but if you
open your project files here it then opens them in mLink (the web browser version of mBlock 5). This is
rather confusing when you already have the software open and are already using it The screen-shot
image below shows how the mBlock 5 ‘Edit Page’ looks at initial start-up.
The ‘Edit Page’ is the descriptor for the main mBlock 5 interface and it occupies the whole of the screen
below the title bar. It is comprises three dynamic panels containing six parts or sub-sections.
In the top-left corner is the ‘Stage’. This is the core-component display area of the traditional Scratch
application and it can be used to display useful visual feedback from ‘reporter’ blocks and the values of
‘Variables’ and ‘Sensors’. There are three buttons immediately below the stage, the first is the
‘Presentation Mode’ (full-screen display) icon and then two buttons to adjust the size of the stage. The
first of these is the default setting and the second reduces the stage size by about 50% from the default
size (and consequently also shrinks the panels below it). The main purpose of shrinking the size of the
stage is to increase the working area of the ‘Scripts’ panel which will now fill most of the right-hand
side of the screen.
Also below the below the stage display, are the two buttons to start and stop scripts - the ‘Green Flag’
button and the red ‘Stop’ button.
Next, to the ‘Stage’ area panel and towards the centre of the interface is the ‘Blocks’ area. Here you can
choose from several categories of programming blocks. If you click on any of the colour coded category
buttons (see the screenshot on the previous page ) then the sub-section to the right changes to show the
available programming blocks for that category - this panel defaults to the ‘Show’ category of blocks.
On the right of the edit page, and initially totally blank, is the biggest panel area (its size dependent upon
the size & resolution of your screen display) - this is the ‘Scripts’ area where you create your mBlock
programmes by dragging blocks from the blocks categories and assembling them into script sequences
as required.
There are three buttons at the bottom-right of this panel enabling you to zoom-out and zoom-in in
20% increments which enable you to see more or less detail of large block scripts. The (=) button
returns the panel to back to its default scale. Any zoom setting that you set is remembered and
remains in force the next time you open mBlock 5. I always try to create short scripts which fit
within the ‘Scripts’ area without any need to zoom-out or any scrolling up-and-down to see their
contents.
At the very top and on the extreme right of the ‘Scripts’ panel are two tabs. The default is labelled
‘Blocks’ - this is where you are right now, ready to create block scripts. The second of these two tabs is
there to open one of the two programming editors; so its label will vary depending whether you are on
the ’Devices’ tab or the ‘Sprites’ tab. If you are on the ’Devices’ tab, then it will be labelled ‘Arduino
C’ but if you are on the ‘Sprites’ tab then this will be labelled ‘Python’.
You need to be aware that if you have the ‘Devices’ tab selected, then clicking on the ‘Arduino C’ does
exactly that - it opens up an editor for programming in ‘Arduino C’ not ‘Python’. If you switch to
'Upload Mode' and use the (</>) 'pull-me-out' icon (shown on the next page) on the right edge of the
interface, this will show any Arduino code generated by your programming scripts.
Very usefully, this programming text can be copied and pasted into the Arduino editor to experiment
with this textual programming code if you want to; and similarly, with the ‘Sprites’ tab selected, then
clicking on ‘Python’ opens the ‘Python’ editor.
This too does not initially show any Python code equivalent to your block programming script, but if
you click the 'pull-me-out’ icon as described above it will also show you the textual code that the your
scripts have generated & you can also copy this and paste it into the Python editor screen for further
experimentation.
Below the ‘Stage’ area and the three display buttons is the ‘Devices’, ‘Sprites’ and ‘Background’
categories panel, the contents of which change depending on which of the three tabs is currently active.
It defaults to displaying the ‘Devices’ tab on the left and the ‘Connect’ / ‘Mode’ sub-panel on the right.
If the ‘Sprites’ tab is activated, then the left-hand part becomes the ‘Sprites List’ and the right-hand
panel shows the buttons to access the ‘Costumes’ and ‘Sounds’ editors. However, if the ‘Background’
tab is activated then the left-hand part shows any added backdrops and a (+) button to access the
‘Backdrops Library’, whilst the right-hand panel remains the same by still showing the buttons to access
the ‘Costumes’ and ‘Sounds’ editors.
Before you start to control a connected robotics device (e.g. mBot) with mBlock 5 for the first time, a
window might pop up asking you to ‘Update Firmware’ and you should follow this advice by clicking
‘Update Now’. It will take 2 to 3 minutes for the device firmware to upgrade and you will need to close
& then restart mBlock5 to activate the upgrade.
On the right edge of the interface near the top of the ‘Scripts’ panel is a tab which suggests a fly-
out option. When clicked, this opens a sub-window which shows either ‘Python’ code as a
comparison to ‘Sprites’ block scripts or (if you are in ‘Upload’ mode) ‘Arduino’ code as comparison to
‘Devices’ block scripts.
Both code display types can be rolled back to the right- hand edge of the interface by clicking the
close icon which replaces the 'pull-me-out' icon when the code window is activated.
As mentioned on the previous page, the left-hand panel below the stage is divided horizontally, and the
bottom half is the ‘Devices’, ‘Sprites’ & ‘Background’ categories panel (one tab for switching to each).
But also, part of this sub-panel is taken up with the ‘Connect Your Device’ area.
Giving the stage a sensible background rather than its remaining blank does improve the look of the
mBlock 5 interface and it is worth noting that a ‘thumbnail’ of any created backdrop image becomes the
icon for your file within the 'My Projects' management page.
mBlock 5 files saved to your computer do not have the thumbnail mentioned above; but
there is a rather nicely designed new mBlock 5 icon instead (shown here on the right).
Secondly, we will consider the rather more important ‘Sprites’ tab. ‘Sprites’ at their
simplest are characters that can be moved about on the stage to play a game or tell a story.
Like the ‘Stage’ itself, ‘Sprites’ are an essential part of Scratch projects where you create
scripts for each sprite causing them to move or interact (essentially, to ‘act’!). Sprites can nevertheless
become useful graphics to enhance robotics projects - see Chapter 14 (pages 83 to 95). In earlier
mBlock iterations, ‘Devices’ did not exist, and you could only add robotics block scripts to ‘Sprites’ -
but now in mBlock 5 you can only add robotics block scripts to ‘Devices’.
Thirdly and finally; and most important of all for robotics work is the ‘Devices’ tab. You can have more
than one robotics device available in the interface, but you can only connect to one of these devices at a
time.
With the ‘Devices’ tab selected, the panel shows the chosen robotics device (or multiple devices) and by
default it shows ‘Codey’ the ‘Codey-Rocket’ robot. There is also an ‘add more devices’ (+) button and
the 'Connect' sub-panel is to the right. Here, you simply click the ‘Connect’ button to make a
connection to your chosen device - but more about the complexities of connecting your computer to a
robotics device a little later…
… In the diagram on the previous page I have deleted the ‘Codey’ sprite (yes, confusingly, device
images are called sprites too!) and I have added the ‘mBot’ sprite since that is the device that this book is
all about. It is here that you can choose to add another robotics device from the list, e.g. ‘mBot’. To do
this, I pressed the (+) icon in the bottom left panel which opened the ‘Device Library’ window.
If you double-click on any icon in the ‘Device Library’ then it will be added into the bottom panel of the
interface (and you can have more than one mBot icon here, but I’m fairly sure that this is not really a
good idea!). If you do not want a device to remain in the interface (e.g. ‘Codey-Rocket’) then you just
click on the (X) button on the corner of the device sprite to remove it.
Device sprite icons in the device library have three states. Newly added and previously
unused device sprites have a green plus-sign (+) button in the corner indicating ‘new’. The
basic sprite for each device otherwise, is the ‘ready to go’ (OK to use) icon shown top-
right; whilst the sprite ‘update needed’ (this device has a firmware update available) has a
green download arrow button in the corner of the sprite as shown bottom-right.
Click this green button to download the update; but do remember that you must then close down and
restart the app. to enable the update.
It’s very important to realise that if you click on the ‘mBot’ sprite here in the ‘Devices’ panel it will
cause the programming blocks in the ‘Blocks’ area to dynamically change to ‘mBot’ specific
programming blocks from what were by default ‘Codey’ specific programming blocks. The number of
block groups available to each device changes too; clever stuff, and very fast!
Ignoring the ‘Scripts’ panel occupying most of your screen, the left-hand part of the ‘Edit Page’
interface looks essentially like the screenshot shown on the next page.
mBlock Web does work very well but installing mBlock 5 software on to your PC to work ‘offline’ is a
good idea. I have already mentioned that the ‘Sign-In’ icon on the menu bar of mBlock 5 will open
mLink. You can download mLink if you need to from the address shown below; and as mentioned on
page 6 you can also download mBlock5 and its predecessor mBlock 3 for a variety of different computer
platforms from the following address:
http://www.mblock.cc/mblock-software/
If the ‘Mode’ switch (which is just above the ‘Connect’ button in the ‘Devices’ panel) is pushed to the
right and is blue in colour then it is in the ‘Live’ (ON) position; if you slide it to the left, it turns grey to
indicate the ‘Upload’ (OFF) position.
You only need to use ‘Upload’ mode if you want to upload a script that you have written into mBot’s
flash memory to enable mBot to run independently from your computer in what is also called ‘Offline
Mode’. You also need to use ‘Upload’ mode if you want to see your scripts in Arduino code.
It’s opposite, ‘Live’ is the norm; also known as ‘Online Mode’ or ’Test Mode’ this (for normal, everyday
programming usage where you don’t have to upload codes into a stand-alone mBot) is where you can
control mBot as long as it is connected to your PC by either cable, wireless or Bluetooth dongle.
It doesn’t seem to matter if your device; ‘mBot’ in our case, is switched on and the serial lead connected
before you attempt to make the connection - any permutation or any order in doing this seems to work
and for the majority of users, this should always work seamlessly.
The ‘Connect’ dialogue screen (on its default USB tab - shown
here on the right) recognises that a device has been connected
and will show the COM (serial) port trying to connect. If not, it
just waits until you switch mBot on and connect the serial lead
between the device and the computer; and once a connection is
detected the dialogue box will show the connection port number.
In either case, you then just click the ‘Connect’ button at the
bottom of the dialogue and mBot will beep once to acknowledge
that a connection has been made.
Remember to close the app. afterwards and then restart it again to enable the update.
Despite Makeblock suggesting that connecting devices to mBlock 5 is easy (which by-and-large it is)
everything is not always as straightforward as suggested and from what I have seen on internet sites,
other users have experienced similar connection issues too and, in my opinion, a little more explanation /
discussion on the connection of Makeblock’s robotics devices would be gratefully received by many
users if Makeblock could detail these clearly.
The second time I tried to connect mBot to mBlock 5 it just would not show a COM port to enable a
connection to be made - nothing! Later I tried again - and making a connection this time worked OK.
This went on and on for days and days with what appeared to be an intermittent connection problem -
how strange & why?
I tried what other users had been recommended on the Makeblock Forum - reinstalling the software - no
different - running it as an administrator - no different. I also tried rather more advanced techniques like
uninstalling all of the USB Hubs in my PC’s ‘Device Manager’ and rebooting to let it reinstall drivers
etc. and nothing; just still the same intermittent connection issues.
In my PC’s ‘Device Manager’ >’USB Hub Properties’>’Power Management’ section I prevented all of
the USB Hubs turning off to save power - still nothing.
I manually reinstalled the USB-SERIAL CH340 driver which provides the serial link to mBot too and
still had the same (and increasingly annoying) intermittent connection problem. Strangely, the
connection between my PC and mBot always worked when I switched back to using mBlock 3 and
when I got around to connecting my Surface tablet to mBot using mBlock 5 it always worked there too
with no connection problems at all.
So, the problem looked to be with my desktop PC - a hardware conflict somehow, and then only
sometimes…
…One afternoon, after a particularly annoying and frustrating session of trying to connect mBot to my
PC, I gave up and was on my way out of my study when my printer ‘gonged’ as it shut down (which it
does after a couple of hours of inactivity) a light-bulb moment - THE PRINTER had been ON! So, I
went back and restarted mBlock 5 and it instantly saw that the ‘Connection’ panel showed a connection
on COM5. I clicked to make the connection and mBot was immediately controllable from the PC.
So, a good habit: - Always shut down a printer before trying to connect with mBot.
When a connection is made, the connect / connected panel shows ‘Device connected’, and you can see
from the diagram above that mBot is the active device. As well as the ‘Upload / Live Mode’ switch
there are now two new option buttons at the bottom of the panel; a ‘Disconnect’ button and a ‘Settings’
button.
Makeblock has not made the significance of these buttons very clear at all. If you click the ‘Setting’
button, it clears the panel and shows at the top just one uninspiring blue text option entitled ‘Update
Firmware’ - this text doesn’t look like a button, but it is and if you hover over it then does look like a
blue button - click it and a new dialogue box will appear in the middle of the screen and this dialogue
box is VERY important.
The dialogue box that has just opened shows that the chosen device is mBot and it gives you two
choices…
… If you click in the ‘Firmware Version’ box (see the diagram below) then you have the option to
choose to update either 'Online firmware’ OR 'Factory firmware’.
Online firmware updates mBot with the latest operating system firmware from Makeblock; whilst the
other setting, Factory firmware resets mBot’s flash memory to the latest update of the default settings.
You may have probably (as recommended earlier) updated the ‘Online firmware’ to the latest version,
but if not, you should choose that option now by pressing the blue 'Updates' button to update mBot with
the latest firmware version available.
On completion, the dialogue box suggests that you
shut down the device (mBot) & restart it and
connect to mBlock again and you should do as the
dialogue requests. mBlock will then connect to
mBot just as it did before with everything working
as it should.
I don’t know why mBot misbehaves but this sometimes happens, and other users have documented it
frequently on Makeblock forum pages. So, if you are working with the robot on a table, bench or
desktop then beware!
Look upon ‘Device Firmware Updates’ as a sort of ‘blood transfusion’ for mBot’s mCore brain. Do not
be afraid of giving mBot’s firmware another ‘shot’ if you feel that you need to. Other mBot users
(particularly in mBlock 3) have recommended device updates as a cure-all panacea and you will find
that it usually stops any unpredictable behaviour if you re-run the same script that you were testing
before.
Downloading and installing the latest Windows Arduino Board Driver from Makeblock is not a bad idea
either as part of this global ‘blood transfusion’. Makeblock boards use an FTDI chip for their serial
connections. In the older mBlock 3 software, there is an option under the ‘Connect’ menu that says
‘Install Arduino Driver’ which sets up the serial driver that needs to be installed for Makeblock boards.
In mBlock 5 however there is no such option.
So, there is a lot more to making a successful connection between mBot and mBlock 5 via USB than
users are led to believe; - but what about connection via Bluetooth.
If you have Bluetooth available on your own PC, then when the ‘Connect Device’ window pops up you
would think that you are just meant to choose the ‘Bluetooth 4.0’ tab on the ‘Connect’ panel and
the Bluetooth port of your device would be automatically detected and you would then expect to just
click the ‘Connect’ button again…
… HOWEVER, mBlock 5 doesn’t currently support any Bluetooth connection with PC’s with
either built-in (or external) third-party Bluetooth! I have asked Makeblock and they say that they are
trying to make mBlock 5 support third-party Bluetooth just like mBlock 3, but to solve this problem it
was suggested by their support team that I had to buy the Makeblock Bluetooth Dongle which has been
specifically created to communicate with their robots.
They suggest that the official Bluetooth Dongle guarantees compatibility and they say that they are not
sure whether any other third-party Bluetooth dongles are compatible with their robots as connection
issues when trying to use these are individually hard to solve.
Makeblock say that you just plug their Bluetooth dongle into any available USB port on your PC,
power-on mBot, pair them, and start programming.
Theoretically, you just plug the dongle into any available port
on your PC and it then very straightforwardly pairs up with
mBot which allows them to successfully establish a connection
with each other.
Since this is called a ‘Bluetooth’ dongle, I thought naively (& why wouldn’t I?) that you had to
choose the Bluetooth 4.0 tab in the ‘Connect’ dialogue window; and try as I might I couldn’t get the
mBlock 5 software to see any available devices.
Eventually (several hours later) after reinstalling the software, trying different ports, restarting the
computer etc. etc. I switched back to the USB connection tab in the connect device window and just
happened to notice that the COM port had changed from the one I had been using for a serial lead
connection (COM4) to the port on the front of my PCs case (COM5) - the port where I had plugged in
the dongle.
I pressed the ‘Connect’ button and ‘hey-presto’ a connection was made, mBot beeping once in
acknowledgement and working perfectly and untethered from the PC for the first time using mBlock 5.
On checking my PC, it showed in the ‘Device Manager > ‘Ports (COM & LPT)’ section: ‘USB-
SERIAL CH340 (COM5)’ as opposed to seeing ‘USB-SERIAL CH340 (COM4)’ which it does when I
connect using a serial lead (and the dongle worked in exactly the same way on my Surface tablet too -
which has built-in Bluetooth).
The dongle also worked fine when I tested it with mBlock 3, connecting as a serial device (as described
above); and it also worked with no conflicts whilst my old external Bluetooth USB Adaptor device was
still plugged in the same port on my desktop PC where it had always been.
Do remember that only when the mBlock 5 software on your PC and the mCore board on mBot are
connected to each other, can you control mBot by writing ‘Scripts’.
I use the USB Serial Cable most of the time and switch to Bluetooth only when I want to operate
mBot running free on the ground - a cable does restrict the travel distance of mBot considerably.
The controlling connection can be by either Serial Cable, Bluetooth or, if applicable (because you
bought the education version), 2.4GHz wireless. You can solve the problem of communicating with
mBot without a wire being attached to it. by using the aforementioned USB (Bluetooth) dongle or the
alternative to the standard Bluetooth module on mBot, the 2.4G wireless module. Setting up a 2.4G
connection if you have this, is very straight forward. Just insert the 2.4G adapter (receiver) into your PC
and pair it with the 2.4G module on mBot and after successful pairing, just click ‘Connect’. Do
remember too, to turn mBot ON with the little switch on the side of the mCore board!
On power-up, and again when the USB serial lead is inserted, mBot outputs three rising notes on its
buzzer followed by both of the LEDs on its mCore board flashing Red, Green, Blue and then turning
White to signify ready. Sadly, the White LED lights remain on and you have to (but don’t need to) turn
them off using a suitable programming block by setting all of the colour settings to 0. When connecting
mBot to your computer the PC produces a short burble of sound in acknowledgement of the connection
being made.
The connection made, everything is ready - you are now able to begin your mBot / mBlock
programming journey and test your mBot for real.
After power-up and connection I usually test that mBot is connected to mBlock 5 by carrying out the
following quick test. In the ‘Blocks Area’ switch to the
‘Show’ categories of blocks. The topmost block in this
category is the stack block shown on the right:
There is no need to drag this programming block on to the ‘Scripts Area’ of the mBlock interface - but
you could if you want to. This block sets the colour of the mCore LED lights and if you just click it (see
the guidance advice below) then mBots LEDs will both briefly turn red and then go off again.
N.B. A good technique to develop when clicking on programming blocks (to either drag them or activate
them) is to always avoid any areas on the block expecting input e.g. avoid the ‘all’ arrow or the
‘shows colour’ or the ‘red’ coloured bubble window or the ‘1’ secs bubble window (all of which can be
seen in the block above).
When you first turn on mBot, it should be in IR control mode by default and the on-board RGB LEDs
are both white.
If mBot is in ‘Obstacle Avoidance’ mode, then the on-board RGB LEDs are green. Place mBot on the
floor, and watch it avoid obstacles.
If mBot is in ‘Line-Following’ mode, then the on-board RGB LEDs are blue. Place mBot on the black
line-follower map and watch it track around the figure-of-eight line.
Pressing button A on the IR remote will stop mBot in Obstacle Avoidance and Line-Following modes
using, whilst the arrow keys can be used for manual driving /steering and the number keys can be used
to set mBot’s speed - 0 = slow & 9 = fast!
Remember, you may need to change mBot back to its default ‘Factory Firmware’ setting if these IR
remote-control mode settings do not work correctly. This can (as mentioned on the previous page) be a
source of much confusion if you forget to do so.
The original mBot app was probably the first mBot app to be written by ‘Xeecos’, an Android
developer specialising in robotics stuff. It is no longer available in the Google Play Store.
This app made a Bluetooth connection with mBot easily and it started online in ‘Manual Mode’ by
default. This is where you can drive mBot with a ‘joystick’ type controller which has an illuminated
speed indicator - this seemed to be programmed incorrectly - mBot turns left when the joystick is pushed
right & turns right when it is pushed left. Forwards & Backwards are OK - funny, but the joystick on
the rather similar ‘Drive’ screen of the much more workmanlike Makeblock app (described on the next
page) has just the same error.
The interface has four buttons on the right of the screen - one to toot the buzzer which is very boring and
just toggles through 7 pre-defined tones; a ‘Speed Up, button which does not as you would expect alter
the speed of mBots motors - it just gives a 5 sec. burst ahead with an on-screen countdown timer; and a
light button which toggles through 6 simple (& also rather boring) changes to mBots LED lights.
On the left of the interface is a vertical strip containing five more main-function controls:
• ‘Unmanned’ which should be ‘obstacle avoidance’ mode, but it doesn’t seem to avoid things at all!
• ‘Manual’ (as described on the previous page). This is the default control - manual driving mode.
• ‘Track’ which is the standard line following mode, mBot runs slowly, but it works very well.
• ‘G-Sensor’ is possibly the best feature here and uses phone or tablet tilt to control steering.
• ‘Shake’ mode has a switch to set forwards or backwards movement and a then a violent shake of
your phone or tablet will move mBot a bit (about 60mm a time).
If you do have a suitable phone or tablet, then you do need to install the much more sophisticated
Makeblock App, also written by Xeecos which can also be downloaded from Google Play store.
N.B. I couldn’t do this when we first got mBot because at the time of testing, my phone was a ‘steam-
driven’ Galaxy SII and is not modern enough. I updated the operating system to Android ‘Jellybean’
4.12 (the highest update possible) but the Makeblock App needs ‘Jellybean’ 4.3 or newer to be
compatible. I couldn’t do this with my own tablet either because it’s a Microsoft ‘Surface’ which is not
supported. So, to test it I had to ‘borrow’ Emma’s Galaxy tablet whilst she was asleep!
Makeblock 3.4.0 is available for Android (Intel x86 chip) devices and at last I now have it on my new
Galaxy Note 9 phone. The Makeblock App is a free and easily downloadable app for both Android and
Apple devices that has been specifically designed for controlling a variety of Makeblock robots.
The Makeblock App’s icon looks like the image on the left. It pairs very easy with either a
phone or a tablet and it connects automatically with mBot via Bluetooth. Once the
Makeblock App is installed, you can play with mBot immediately and it has controllers for
all the default functions that you can choose with the IR remote or the on-board button.
On a large screen tablet (or my new ‘phablet’) this is great, but it is quite hard work using this app on the
screen of a small phone. The software uses ‘Tiles’ which you scroll through and click to choose options
and sub-options and there are the following tiles to choose from initially:
• ‘Play’ - this tile has a choice of 4 modes: ‘Drive’, ‘Draw & Run’, ‘Musician’ or ‘Voice Control’.
• ‘Code’ - this links you straight into the mBlock ‘Blockly’ App which Makeblock have developed to
teach the basics of coding using mBot & mBot Ranger (described in some detail on the next page).
• ‘Create’ - this tile is probably the best of these options and it is where you can drag controls to build
sophisticated consoles (as shown in the diagram on the next page) and then save them. I was amazed
to find that the app has controllers for the most popular of mBots optional add-on packs too! There
are in fact more than 30 predefined modular components which can control different sensors or
execute various commands.
• ‘Build’ - this shows a wonderful (but rather pointless since you’ve probably built it already) 3D
animation of how to assemble mBot.
• ‘Expand’ - this opens a sub-menu of several control options for the optional add-on pack models.
The mBlock Blockly App is a supposedly ‘game-based’ app (built once again by Xeecos)
for Makeblock programmable robots and it has an icon that looks like the image on the
right. It is a simple programming learning centre using drag ’n drop block programming
where you can only progress by completing sections in sequence. Makeblock say that it
introduces students to the world of robotic programming on mobile devices. They describe their variant
of Blockly as 'immersive game-based learning' where you complete tasks and learn coding skills
gradually using intuitive block-based programming. They describe these tasks as 'games', but they
aren’t really games (unless the whole experience of programming mBot is seen as a game!).
These simple tutorials are quite easy to follow but you can't progress to the next level unless you get the
current exercise correct and this can be a little off-putting at times if you don’t quite get the point of
what is being asked (since they are not always described in grammatically correct English).
Also, whilst you are in the tutorial there is no opportunity to experiment with scripts of your own which
is also a bit frustrating for a bright young user since each exercise only makes the relevant blocks
required for the exercise available, leaving most of the block categories greyed-out; and moving on to
the next exercise is the only option! I was amazed how fast Emma worked her way through each of the
exercises (although she did get stuck once) and she was very pleased with herself when she completed
all of the tasks on each of the ten levels.
However, this app. does have an annoyingly incessant background track sound (and ‘Mr Panda’ as a
fairly sedentary ‘instructor’) and it is also hard to exit since there is no back button allowing an easy
return to the main tile (menu) group.
The tutorials though are fun nevertheless and I think that I would recommend this as a first step to
programming mBot for young children since they do get the satisfaction of making the robot do
something themselves at every stage of the ten levels of instruction. These ten levels can be completed
by a competent adult in about an hour.
After completing all of the tasks you then have some understanding of how the ‘Blockly’ interface works
and now, when you click the ‘Create’ button at the bottom of the main screen, you finally get access to
the full ‘Blockly’ programming interface with all of the block categories available.
Since this is written in 'Blockly', the blocks are a little different to those used in Scratch and mBlock 5,
but the principles and concepts are very similar, and I have seen first-hand that a bright eight-year-old
can very easily transfer the skills gained here to programming in mBlock 5 after using the ‘Blockly’ app.
‘Blockly’ dates back to 2011 and whilst not quite the same, visually resembles Scratch. It is a Google
open-source library project for drag-and-drop block coding and typically runs in a web browser. It is
primarily used for computer science education but also gives advanced users a way to write their own
scripts for app creation. It has a very neat way of changing which blocks are shown in the toolbox
palette on the left of the interface too. Blockly can be used to generate JavaScript, Python, PHP or Dart
code and it can also be customised to generate code in any textual computer language.
mBots box does state clearly that batteries are not included and mBot comes with a battery pack to
which you need to add 4 AA batteries - it is shown in the instructions being attached to mBots chassis
using ‘Velcro’ strips - we omitted these which sensibly allowed the battery pack to slide in-and-out from
under the mCore board whenever we needed to change the batteries. The four ‘Duracell Plus’ batteries
we inserted at build-time lasted about 4 weeks of daily use.
N.B. In addition to the above, the IR remote needs a CR2025 3V Lithium, button type battery (e.g.
Panasonic CR2025) also not supplied in the box. These cost about 40p each.
…BUT on my mBot, low batteries were the cause of a rather worrying blinking
LED and Tick-Tick sound problem (and possibly an ‘iffy’ Bluetooth connection
problem too). All Arduino boards do blink a tiny LED light (marked by an L
printed next to it on the board).
Note: - Everything does get sluggish (inc. your scripts) when the batteries are low.
After about 6 weeks, I took the plunge and we switched to using a 3.7V
rechargeable Lithium Ion Polymer (LiPo) battery which is very practical no copyright
infringement is
as the mBot board can charge the battery via its USB cable. These are intended with
thin, light & powerful and include integral protection circuitry. the use of this
image
I had thought of buying one from China via eBay since sourcing one of
these in the UK seemed initially to be difficult; and what about getting
the right connector? (the eBay pages were a bit vague on these) - it
needed to be a 2mm pitch JST-PH connector (which is a 2mm spacing
between the pins) - but then I found that the excellent and friendly ‘Cool
Components’ in Hampshire had 2000mAh ones in stock for £15.50 (inc.
speedy delivery - within 24 hours!).
Pundits in the USA advise a 2500 mAh LiPo, however 1000 or 1200
mAh batteries are quoted as being quite acceptable so I am expecting the
2000mAh one to work well. A small battery box (measuring 50mm x 33mm x 10mm) is supplied as
part of the mBot components but this was far too small since the 2000mAh LiPo battery that I had
bought was 54mm x 54mm x 6mm. This was not a problem since we just used one of the ‘Velcro’ strips
omitted earlier to hold it in place under the mCore board - this is a good arrangement. It’s hard to
understand Makeblock’s reasoning for including a LiPo battery box but with NO information on
purchasing a suitable LiPo battery to fit in it.
When you plug the USB cable into mBot with a LiPo battery attached, one of two charging LEDs near
the JST port light up. A steady red light indicates charging whilst a solid green indicates a fully charged
battery. Apparently, if the green LED is flashing, it indicates a dead / bad LiPo battery. My new battery
worked as prescribed and had some power in it, but it was fully charged after about 2 hours on USB.
With mBlock 5 software installed on your computer you can easily programme Scratch code sequences
by just dragging, dropping, linking and fitting together colour-coded building blocks that represent
control structures, assignments or actions.
To create a script, you just drag blocks out of the ‘Blocks’ area and graphically assemble them as a series
of connected blocks in the ‘Scripts’ area. A Scratch (or mBlock 5) script is defined as a set of blocks
that begins with a ‘Hat’ block and therefore usually consist of at least two blocks.
A script fragment is a block or set of blocks in the scripts area that is incomplete because it is missing a
‘Hat’ block. It is possible to run script fragment blocks by just clicking on them in the ‘Blocks’ area of
the interface (as mentioned on page 28). This page also described a good habit to develop when clicking
on programming blocks (to either drag them or activate them) - always avoid clicking on areas on the
block expecting further user input. A script fragment will not run during normal execution of a project,
because nothing triggers the code, but they do have their uses to set, or reset, things.
To start or ‘Run’ a script, just click on its ‘Hat’ block or press the ‘Green Flag’ button below the stage.
To remove a script, either right-click and choose ‘Delete Block’ or click and drag it over the ‘Blocks’
area where you will see it turn grey and a ‘Trash Can’ icon will appear - just let go of the blocks
anywhere when this area turns grey.
The order of blocks in a script is very important as they determine how sprites interact with each other
and the stage backdrop. It is considered good-practise to attach ‘Comments’ boxes to ‘Scripts’ to
explain what certain blocks do and what the script's purpose is - I always try to add a comment to every
script to describe its purpose and other comments for individual blocks if an explanation or reminder is
necessary.
After you have created your scripts in the ‘Scripts’ area of the interface you can (but you don’t have to)
right-click the background and select ‘Clean Up Blocks’. Doing so let’s your scripts be organized
automatically and neatly with their left edges aligned. This block alignment doesn’t account for any
comments boxes that you may add to your scripts and these may overlap after an auto clean up.
There are five shapes of programming blocks which can be connected to each other vertically to create
‘Scripts’. Each data type has its own block shape and specially shaped slots, bumps and notches.
‘Stack’ blocks, ‘Reporter’ blocks and ‘Boolean’ blocks are all capable of dynamically resizing too and
will stretch or shrink horizontally to accommodate other blocks or typed data inserted where individual
values are needed. Every block shape is designed so that it can do one or more of the following:
Start a script. End a script. Fit inside other blocks. Contain other blocks.
There are six different block shapes and each type (‘Hat’, ‘Stack’, ‘Reporter’, ‘Boolean’, ‘Wrap’ or
‘Cap’) has its own shape and many have a shaped slot for other blocks to be inserted (or 'nested').
1. ‘Hat’ blocks are the blocks that start every script. They are shaped with a
rounded top and a bump at the bottom, so you can only place blocks below
them. Each Hat block type is activated by a specified method, enabling
different scripts to be started at different times. The general shape of a Hat
block is shown on the right:
2. A ‘Stack’ Block is a rectangular block that can fit above or below other
blocks with a notch at the top and a bump on the bottom for connecting to
other blocks. ‘Stack’ blocks make up most of the blocks available in every
category except in the ‘Operators’ block group. They perform specific
commands and when two or more stack blocks are connected to form a ‘Script’ then their individual
commands will execute in sequence order from top to bottom. The shape of a typical stack block is
shown on the right:
3. ‘Reporter’ blocks are elongated blocks with rounded ends and are designed to fit into,
(nested inside) matching shaped slots in other blocks wherever a value (either a
number or a text string) is needed. They have no bumps or notches and can’t
therefore can't be used alone. To quickly view the value of a reporter block, simply click it and a
pop-up bubble will display its value. A typical Reporter Block is shown on the right:
4. ‘Boolean’ blocks are elongated hexagonal blocks, shaped like the Boolean
elements in flowcharts and they fit into corresponding hexagonal slots in other
blocks; they too have no bumps or notches and therefore can’t be used alone.
A Boolean block contains a condition, which can be either ‘true’ or ‘false’ or the numbers ‘1’ and
‘0’ depending on their usage in a script. A common use for a ‘Boolean’ block is within an ‘If …
Then’ ‘C’ block. A typical Boolean Block is shown on the right:
5. ‘C’ blocks are also sometimes known as ‘Wrap’ blocks. These blocks loop
any blocks contained within the ‘C’ checking if a condition is true before
exiting. There are five types of ‘C’ blocks, found in the ‘Control’
category. ‘C’ blocks can be either bumped at the bottom for further
connecting, or flat (capped).
6. There are two specific ‘Cap’ blocks - ‘Stop all’ and the ‘Forever’ loop ‘C’
block to be found in mBlock 5 in the ‘Control’ category. Cap blocks are used
to terminate scripts. They are shaped with a notch at the top and they have a
flat bottom so you cannot place any blocks below them. The general form of a
Cap Block is shown on the right:
In addition to the standard Scratch/mBlock 5 blocks listed above, there is also the
facility to create very useful ‘My Blocks’. These are user-defined ‘custom’ blocks, a
way of compressing a script containing a sequence of blocks into a single stack block
that you name yourself. A ‘My Blocks’ hat block is shown here on the right:
You can perhaps perceive a ‘My Blocks’ block as an alternative to a hat block since they are always
needed to start any script sequence of programming blocks.
N.B. They are only visible in (and work in) the sprite (or the device) in which they are created!
It's considered best practice not to have repeated chunks of code in scripts, so using a self-defined ‘My
Blocks’ block only need a single custom stack block to call any code created under it. These blocks can
be used in scripts as many times as you like and save much duplication of block sequences since you
only need to use the name of the custom block every time you want to call the common code; this will
reduce the total number of blocks (and therefore the parsing time) in your scripts.
mBlock 5 needs to parse the entire set of blocks in your ‘Scripts’ area; so breaking up one big script into
smaller scripts is generally a good idea as it reduces the parsing time making your code run a little faster
and smoother. As well as saving time and saving space, using well-named custom stack blocks can also
provide much clarity in a complex programming sequence making your programmes easier to read and
to maintain - so do develop the habit of making your own custom blocks.
Uploaded code is actually more efficient and runs more smoothly when all your instructions are running
totally inside mBot’s brain since the mBlock 5 application is really a code generator. If you do upload
your scripts into mBot it compiles your programme into a hexadecimal source file (that conveys binary
information in ASCII text form (this is a method commonly used for programming microcontrollers,
EPROMs, and other logic devices). Conversely, with the more usual ‘Online mode’ control of mBot
you might experience marginal lag times because of the emulation happening to bridge your code with
mBots hardware. However, for most of the time, there is no need go ‘Offline’ at all - it is rather boring
and somewhat tedious to upload your code into mBot which is then stuck with just that set of
instructions until the equally tedious ‘Upgrade Firmware’ option is invoked. You may also find it worth
it to use ‘Reset Default Program’ to clear out mBots memory too. So do get into the habit of always
working in ‘Online mode’, allowing mBot to provide real-time development feedback on the ‘Stage
using ‘Monitors’, ‘Variables’ and other graphical output from your projects (see Chapter 14 for more on
graphics).
mBlock 5 lends itself to simple procedural coding since there are no complex functions, no multi-
threading, no fancy data structures and only the simplest manipulation of variables. Ideally, you just
work out a decision-making algorithm detailing the Input / Process / Output of what you want to do; and
then write the script - simple!
N.B. An algorithm is a sequence of step-by-step instructions or a set of rules that are followed in the
right order to complete a task correctly.
An algorithm is a procedure that tells your computer precisely what to do (and in what order) to solve a
problem or reach a goal. The task to be solved by an algorithm can be anything, so long as you can give
clear instructions for it and it can be written as a list of steps just using text or mostly, pictorially (a
flowchart) with shapes and arrows showing input, processing and output.
Each block in a script carries-out its designated command in turn in the order in which the blocks are
positioned, from top-to-bottom, and then the sequence stops.
However, if the same Reporter block (nested inside a Stack block) is put inside a ‘Forever’ loop, then
the number on the displayed variable will constantly change as soon as the script is run; this is what is
known as ‘real-time’ feedback! - see the screenshot of both of these scripts below:
In mBlock 5, looping blocks are ‘Control’ blocks which hold other blocks inside them. The most
common of these is ‘Forever’ which is a loop block (shown in the screenshot above) that repeats forever
in an infinite loop; and there are surprisingly, a lot of cases when an infinite loop is needed. Using a
‘Repeat’ block instead will loop a given amount of times before allowing the script to continue.
If you put one ‘Repeat’ block inside another (which is allowed) this is also called ‘nesting’. The total
repetitions will be the product of the two nested ‘Repeat’ block inputs.
The ‘Repeat Until’ block is very similar and will loop until the specified Boolean statement is true, in
which case the code beneath the block (if any) will execute. Note that this loop is in similar nature to a
‘While’ loop in some other programming languages.
Particularly useful and probably the most powerful of the looping blocks are the ones that make
decisions after checking specified conditions such as ‘If…Then’ and ‘If…Then…Else’; both of these
conditions loop until the specified condition is true and then exit the loop.
If you define a variable, then several more stack blocks appear under
the heading ‘Variables’ in the block categories section of the ‘Blocks’
area. They are orange in colour and as you create more variables then
their names are automatically added to the drop-down menu lists in
each of the blocks. The current choice is shown as ‘Distance’ in all the
blocks shown above right.
Variables, generally speaking, can be local or global. In mBlock, a local variable can be used by just
one sprite; however, a global variable (the default setting) can be used by all sprites.
One of the great strengths of mBlock is the ability (and a requirement in many cases) to ‘dock’ or ‘nest’
programming blocks inside other blocks. The example on the previous page using the variable
‘Distance’ allowed a choice from four additional orange stack blocks. The first block in this list; shown
slightly more clearly above is ‘set (variable name) ‘Distance’ to ‘0’.
I used this stack block to create both of the single block scripts in the example shown on the previous
page. Note that the ‘0’ part of this can be changed to anything that you can type or that can be nested
inside the window that contains ‘0’.
In this case, the ‘Reporter’ block for the Ultrasonic Sensor was dragged over the little window until it
‘nested’ inside it (be aware that the rim of the window illuminates with a white rim when another block
is near enough to be nested inside it) - note too that the ‘Set (Variable Name) to…’ block also
dynamically expands automatically to allow any nested inclusion to fit inside it. Blocks grow clearly
wider when something is nested inside them, but blocks grow a little taller (or fatter) too with each
subsequent nesting.
With a little practice, nesting mathematical operators and reporter blocks to calculate meaningful output
becomes very straightforward. As an engineer, I like to have distance readings in millimetres (not the
default measurement, centimetres!).
To do this (as shown below) it needs a slightly more complex ‘nested’ variant of the same single stack
block. First, the sequence is described as a simple algorithm:
Round reading to Set ‘Distance’
Read Sensor Multiply by 10
nearest Integer Variable
Build the nested block sequence in the following order – note that the window in the ‘round’ operators
block is illuminated to show that the ‘nest’ can be made (and note too how the operators block stretches
to accept the ‘reporter’ block):
Add the newly nested ‘round’ block into the left-hand window of the ‘multiplication’ operators block
and type ‘10’ into the right-hand window as shown below:
Finally, add this nest of the three component parts to the round-ended right-hand window of the Set
‘Distance’ Variable stack block to complete the block sequence required to allow ‘Distance’ to report
distances in whole millimetres:
As mentioned earlier, it's considered best practice not to have repeated chunks of code in your scripts, so
you need to develop the technique of making your own ‘user-defined’ custom blocks which you create
by clicking the heading ‘My Blocks’ at the top of the block categories section of the ‘Blocks’ list area.
Named custom blocks that you create here are red in colour and greatly help with the recurring use of
script sequences in a complicated programme since you only need to use the name of the custom block
every time you want to call that piece of code.
After defining a block and creating a script under the (unique to ‘My Blocks’) red coloured hat block
shown on the right of the diagram at the top of the next page, a new stack block with the name you gave
to the hat block is available and visible in the ‘My Blocks’ window enabling you it to add to any other
script sequences as many times as you like - one block such as this can call the whole script stored under
its defined hat block; saving space and providing much clarity in a complex programming sequence.
It is helpful perhaps to consider variables as being containers that hold information; with their sole
purpose being to label and store data in memory which can then be used throughout a programme.
But although variables holding ‘Device’ data can be seen on stage output monitors, any scripts created
on the ‘Sprites’ tab can’t actively use any of this data in their programmes without using the ‘transfer-
data-on-demand-by-message’ broadcasting trick described in Chapter 13 (on pages 77 to 79).
In programming, a variable is a value that can change depending on conditions or on information passed
to the programme. Storing bits of data is crucial to the majority of programming scripts. In mBlock 5
data can be held in either variables or lists and either of these can be used whenever alphanumeric or
boolean values need to be stored and then referenced and manipulated in a script.
The naming of variables is regarded as one of the most difficult tasks in computer programming and you
need to develop a method for labelling data with a descriptive name so that your programmes can always
be understood clearly.
When you assign names to variables, try to make sure that the names are accurately descriptive and
sensibly logical. They should be understandable to either someone else or indeed yourself when you
return to a programme that you may have scripted months or even years earlier.
Creating variables in mBlock 5 is not difficult - in fact it is a fairly simple but marginally tedious task (if
you do need to create many of them), so having a set of useful and logically named variables ready-
made in a setup programme is a good idea.
In addition to creating useful graphics libraries and having them pre-loaded into my ‘mBot Setup Page’
file (previously mentioned on page 21) I have also experimented by added to it my most frequently used
variables, especially those which are needed to enable any of my installed library graphics to be
programmed on mBlock’s stage.
A list of these variables is shown on the next page. Any project based on a set-up file such as this can
contain all of these (even if they are not being used) and it is worth noting that both the graphics and the
variables pre-loaded into a file such as this are much quicker to delete if they are not needed in a project
than they taken to create them! HOWEVER, I have reverted to no longer having any pre-loaded
variables in my setup file.
When creating any project that is likely to be uploaded to Arduino, it needs meaningful
names throughout and especially for variable names, broadcasts and self-defined block
functions.
These should ideally be just one descriptive word or one continuous set of characters
e.g. (using_an_underscore_to_simulate_a_space).
However, if your mBlock projects are not ever likely to be uploaded to Arduino, then
spaces are OK and continuous characters (although a good habit to adopt) are not
important.
About Lists
mBlock’s Lists (called arrays in other programming languages) are a way of storing
multiple pieces of information at once.
A ‘List’ can store and hold data that can be retrieved, added to or acted upon by other
scripts.
A ‘List’ can also be defined as a variable containing multiple other variables. Data
stored in lists in mBlock 5 can be usefully exported as a text file and text files can just
as easily be imported to populate an mBlock 5 list.
Lists are in effect, a simple vertical lookup table which consist of two vertical columns
the first containing ascending numbers which are paired with a second column
containing alphanumeric data; each data item capable of being retrieved by calling its
paired number. When you add a new data line, then a new pairing number is auto-created.
You can see from the short script above how a randomly
generated number can be used to look-up items stored
in the list shown on the right to enable mBlock to
return a text response every time Emma pressed the
‘Space’ bar on her keyboard with one hand whilst
making her own hand gesture with the other hand at
the same time.
This was fun to do, and we made, as you will see later on, many more
sophisticated variants of this game.
All about mBlock 5’s Default Set of ‘Device’ Programming Blocks for mBot
You do need to understand that you can only programme your chosen robotic device (mBot) when
the ‘Devices’ tab is selected and that initially, you only have access to the default set of robotics blocks
available in the blocks area. Slightly more complex programming however requires more blocks than
these to create control scripts and these are added as ‘Extensions’. Robotics extension packs are only
available to ‘Devices’.
Unlike all previous versions of mBlock, ‘Sprites’ no longer support robotics block programming and the
extensions packs of robotics blocks cannot be added to ‘Sprites’ - but more on extensions later. It is
important to realise too that when you switch to the ‘Sprites’ tab, the categories in the ‘Blocks’ area
change completely to show a totally different set of (non-robotics) programming blocks. As
mentioned earlier (on page 18) the ‘Blocks’ area has a set of coloured category buttons where you can
choose from sets of programming blocks that you need to build control scripts. There are nine
categories of these default blocks specifically for the mBot device and when you click on any of these
buttons then the available programming blocks in that category will be visible (short blocks anyway) in
the sub-section immediately to the right. Clicking anywhere on this sub-section panel allows longer
blocks to flow out over the ‘Scripts’ area to show their full content.
Although the block categories remain the same, or very similar, when you change devices, they do vary
for each robotic device depending upon the capabilities of each. ‘Codey Rocket’ has, for instance,
eleven categories of robotics blocks to access whilst ‘HaloCode’ & ‘Ultimate2’ robot have nine and
‘mBot Ranger’ only eight.
The first four of mBot’s block categories are ‘Show’, ‘LightSound, ‘Action’,
and ‘Sensing’ and all of the blocks in each of these have a device image at
the left hand end of the block (a lovely new mBlock 5 design feature). In the
image on the left you can clearly see that it’s an mBot-badged block and
coloured blue indicating that it’s from the ‘Action’ block category.
The first category of these mBot-badged blocks is ‘Show’ and although it is the first category group, it
has little to do with initial mBot programming since these eight stack blocks are all for creating scripts to
operate Makeblock’s add-on component, the ‘Me LED Matrix Panel’ (known in earlier versions as
‘Face’). This is an 8 x 16 matrix of little LED lights (more about this in Appendix 1 on page 184) - it is
a very useful output component, but not part of the basic mBot robot! I suspect that the ‘Show’ category
comes first in the blocks categories list to maintain compatibility with ‘Codey’ categories since ‘Codey’
has an inbuilt LED display; but if you want LED matrix output from mBot, then you have to buy it
separately (but it is worth it!). The ‘Show’ blocks are shown at the top of the next page.
The second button in mBot’s ‘Blocks’ categories list accesses the ‘LightSound’ blocks. The five ‘stack’
blocks in this category are itemised below:
With these blocks you can write scripts to control very simple output from mBot using the coloured
LEDs and the sound generator buzzer on the mBot’s mCore board.
The third button in mBot’s categories list accesses the ‘Action’ blocks. The seven ‘stack’ blocks in this
category (shown below) allow you to write scripts to control the two electric motors that power mBot.
The fourth button in mBot’s categories list accesses the ‘Sensing’ blocks. These blocks are different in
appearance to those in the previous categories shown above. There are ten blocks in this category which
are shown below:
Out of the ten ‘Sensing’ blocks, there are only two ‘stack’ blocks, the remainder being ‘reporter’ or
‘boolean’ blocks. Four of the five ‘reporter’ blocks have a check-box, which if ticked, will show the
reported result (feedback from that reporter) on mBlock’s stage in the same way that ‘Variables’ can.
The final three blocks in this category are ‘boolean’ blocks shaped to fit into matching hexagonal holes
in ‘control’ or ‘operator’ blocks to enable decision making within that block. Below the first four mBot
block categories described here and on the previous page are three more categories which do not carry
the ‘mBot specific’ badge described earlier.
These categories are the ‘Events’, ‘Control’ and ‘Operators’ blocks which can be considered as
‘general-purpose’ programming blocks (all very similar to their Scratch 3 counterparts). Blocks in the
‘Events’ category comprise the five ‘hat’ blocks and the two ‘stack’ blocks which are shown below.
The ‘when key pressed’ hat block is pointless on its own since it performs in exactly the same way as the
more usual ‘when green flag clicked’ hat block - namely starting a script action with no way of stopping
it without clicking the ‘stop’ button below the stage or clicking the same ‘hat’ block again.
The ‘when () key pressed’ hat block still provides a useful way of running a script by pressing a
designated key on your keyboard; but since there is no ‘when key released’ hat block you can no longer
hold down a key (i.e. ‘the space bar’) to run a script and then exit the script as soon as you release
the key (as you could in mBlock 3).
This key pressed / key released combination was, in the past, important for simple robotics control - a
serious omission error here by the MIT Scratch team surely?
The eight blocks in the ‘Control’ category are identical to their Scratch counterparts. The three ‘stack’
blocks and five ‘C’ blocks in this category are shown below:
There are eleven ‘reporter’ blocks and seven ‘boolean’ blocks in the ‘Operators’ category, and these are
very similar to their Scratch counterparts too. These blocks are shown below:
The final two mBot programming block categories are ‘Variables’ and ‘My Blocks’. Neither of these
categories contain any blocks on start-up because you have to create your own block as you need them.
Pressing the (+) icon at the bottom of the ‘Blocks’ panel (beneath the coloured block category buttons)
opens the ‘Extensions Centre’. This window shows totally different contents depending upon
whether you have the ‘Devices’ tab active or on the ‘Sprites’ tab active.
In addition to the default robotics blocks for programming devices listed in the last two pages, there are
twelve extensions the ‘Extensions Centre’ when it is opened from the ‘Devices’ tab. You can however
only see eight and it’s not very clear that the window needs to be scrolled to see the remaining four.
Four of them: ‘Light Sound’, ‘Servo’, ‘Sensing Gizmos’ and ‘Gadgets’ contain between them just 11
different robotics blocks (with some rather confusingly being repeated in these extensions three times!).
However, these 11 blocks plus another 26 blocks (making 37 different blocks in total) are all contained
in just one extension, the ‘Maker's Platform’ extension. This is almost certainly the only extension that
you ever need to load for the majority of your projects. So why ever bother loading the other four listed
above? If you do ever have the need to load these then it is worth noting that the ‘Light Sound’
extension has robotics programming blocks for LED control and light and sound sensor feedback.
The ‘Servo Pack’ also has the same blocks for LED control in addition to those for controlling servo
motors. The ‘Sensing Gizmos’ extension has blocks for basic electronics work inc. fan control and
sound and temperature sensor feedback whilst the ‘Gadgets Pack’ extension also has the blocks for LED
control and for controlling servo motors as well as limit-switch control and digital display output.
I’m not too sure yet where I stand on the usefulness of ‘Extensions’ - either for the ‘Devices’ tab or
for the ‘Sprites’ tab especially since the remaining seven extensions for the ‘Devices’ tab are (for a
variety of reasons) of very limited use.
I’m not sure if the ‘Data Chart’ extension is of much value at all - it links to ‘Google sheets’ but it’s
only available if you are using the mBlock 5 web browser version. The list of blocks in this extension
appear to be very limited in what they can load or edit. The ‘Upload Mode Broadcast’ extension
enables a device to interact with a sprite when it is used offline - occasionally useful, but generally a
very rare occurrence!
The ‘Bluetooth Controller’ extension enables the connection to a hand-held games type controller via
Bluetooth. This might be of value to enable direct control of mBot if you already have one, but you can
do that already with the little IR controller supplied with mBot. There are just two blocks in this
extension, and they are greyed-out (dimmed) until a device is connected .
Specific Makeblock Me module boards (rather than the more commonly available add-on packs) are not
an easy thing to source in the UK and at an average cost of £15 to £20, plus considerable shipping costs
are rather expensive to source.
The ‘Audio Player’ extension is for advanced recording, manipulation & playback of external sound
files. BUT this needs a specific Me audio playback module if you want to play or record music or to add
speech recognition to a project.
The ‘RGB Line Follower’ extension like the ‘Audio Player’ above needs the purchase of another specific
Me module. It can be used for advanced robotic line-following, allowing mBot to be programmed to
follow different coloured tracks. The ‘Color Sensor’ extension (like both the ‘Audio Player’ and the
‘RGB Line Follower’ also needs the purchase of a specific Me module which is capable of determining
between six different colours.
I’m not sure what the final extension is or does! - Its not currently activated so you can’t open it and it
might be linked to an Internet Ordering Platform?
I need and therefore regularly use the aforementioned ‘Maker's Platform’ extension and I always load it
into the edit page of all of my projects since it contains many of the useful blocks which were always
present in the good old mBlock 3 ‘Robots’ blocks category.
Once loaded into (and used in) a project, any extension such as this one is remembered and will be
visible in the ‘Devices’ blocks categories (or ‘Sprites’ blocks categories, if appropriate) when that
project is reopened.
I use the ‘Maker's Platform’ extension specifically for its DC motor control blocks which are much
more precise for moving mBot compared to the rather simplistic, ’Move’ blocks in the ‘Action’ category
of mBlock 5’s default sets of blocks.
These DC motor control blocks enable you to run one motor alone or independent of the other and
each can be set to run clockwise or anticlockwise - confusingly the descriptors on these control blocks
refer to DC motors connected to either port1 or port2 - this does not however mean the main connection
ports on the mCore board (it really means the M1 & M2 motor connections)!
Out of the rather long (too long in fact) list of 34 blocks in the ‘Maker's Platform’ extension the
following five stack blocks, four reporter blocks and a single boolean block are probably of the most
use:
These are followed in usefulness by the following (although these blocks all do exist in the ‘Show’
category) - and are only of use if you buy the LED panel add-on component:
The remaining nineteen blocks in this extension are really only of use if you have access to specific
control / feedback items which are (as mentioned on the previous page) expensive add-ons not
commonly available:
N.B. Rather confusingly, the ‘Light Sound’ ‘Devices’ tab extension mentioned on page 47 has the same
name as the second of the blocks categories on the ’Devices’ tab which is also called ‘LightSound’.
Fourteen individual sets of robotics blocks (totally different to those discussed on previous pages) are
available for mBot in the 'Extension center' when it is opened from the ‘Sprites’ tab and once again I’m
not sure about the real value of very many of these. However, that said, this software is totally free to
use and Makeblock have made a very good and nobly intentioned attempt at providing the tools to
enable kids to get to grips with the basic concepts of A.I and Machine Learning.
The ‘Cognitive Services’ extension has Artificial Intelligence (A.I.) blocks with an integral on-screen
‘Recognition Window’ showing what your web-cam can see. The blocks work very well in recognising
spoken and written words (both printed & hand-written). There are also blocks which purport to
recognise the age and the emotional expressions of an individual viewed by the web-cam - I’m not too
sure about the value of these last two but experimenting with simple A.I. feedback is quite good for kids.
Technically (and rather grandly), ‘Cognitive’ refers to attention span, memory and reasoning; along with
other actions of the brain that are considered to be complex mental processes!
The ‘Teachable Machine’ extension has initially just one block which accesses a ‘Training Model’
window which enables your computer to supposedly learn things by establishing artificial neural
networks that resemble human brain processes and which can train your sprites to ‘learn’ things - this is
called ‘Machine Learning’. This also has an integral on-screen ‘Recognition Window’ showing what
your web-cam can see. This extension is rather complex to use, and the model relies on you creating
‘categories’ (rather like variables) which, when the model is in use, will become available as drop-down
choices in two of the three new blocks added to the extension. These ‘categories’ are ‘trained’ on what
the web-cam can see, which seems to be rather similar to the A.I. emotions feedback.in the ‘Cognitive
Services’ extension; but here, it I doesn’t appear to work half so well.
The ‘Data Chart’ extension provides a very simple way of building a data table, a bar or line chart on
screen which can be downloaded as a .png file; but why? - This seems to serves no really useful purpose
unless you want to use it to capture the data stored in variable reporter blocks in a graphical way.
The ‘User Cloud Message’ extension can be used to sync data from your mBlock account across
different devices and projects - this is probably useful when you need to upload a programme to a device
like ‘HaloCode’. The ‘Pen’ extension is useful since it allows sprites to draw lines on the stage display
screen. The ‘Music’ extension has its uses too if you want mBot to produce sounds emulating a variety
of instruments (and this now works so much better than the ‘Sound’ blocks group did in mBlock 3).
The ‘Climate Data’ extension does have some value too and has robotics programming blocks for
accessing and manipulating real-time climate data from most towns in countries across the world. The
output from these blocks is rather sparse and ideally needs to be concatenated with descriptive text either
side of the output data; which leads to some very long nested block sequences (but if these are stored as
a named variable then the data string can then be called by just the variable name).
The ‘Upload Mode Broadcast’ extension is exactly the same extension as is found in the ‘Device
Extensions Centre’. This also enables a device to interact with a sprite when it is used offline - and as
mentioned before, useful - but a very rare occurrence!
The ‘Google Sheets’ extension can connect mBlock 5 to a Google spreadsheet of data, but only if the
sheet has been ‘Shared’ and anyone with the link allowed to edit the file. You need to have copied the
link (URL) from the sheet you want to access to the clipboard so that you can paste it into mBlock 5’s
‘connect to shared sheet’ block.
There are only two additional blocks in this extension - one to input data into a named cell, and one to
read data from a named cell. I suppose that you might want to use this as a way of capturing or inputting
data stored in variable reporter blocks; but this seems to be a tedious and possibly pointless undertaking,
so I’ve not tried that yet!
N.B. In a short test of this extension, it took about 8 seconds to poll a Google sheet, edit it and send
feedback to the mBlock 5 stage; and all without the sheet being visibly opened (but this was with me
already signed-in to Google!).
The ‘Video Sensing’ extension senses motion with an attached video camera. mBlock 5 seems to
recognise any web-cam attached to a PC. It does work OK, but it seems to be of rather limited value.
The ‘Text to Speech’ extension works well. It makes your projects talk and you can choose from a range
of voices. I’m not sure as to its real value though, since this very much depends on the nature of the
project in hand; and to work well this needs the words to be written phonetically (so that they sound
right) and not as conventionally spelt.
I tested this by using it to speak a sequence of the ‘Climate Data’ extension variables mentioned on the
previous page. Some climate data output required repeated tweaking before it sounded OK.
The ‘Translate’ extension works very well. It will translate text into many languages. I tested this by
using “The pen of my aunt is in the bureau of my uncle” which it immediately returned in French as
“La plume de ma tante est dans le bureau de mon oncle”.
The ‘Makey Makey’ extension (make-key, get-it!) literally allows you to make a simple key code to
operate a hat block. Fun for kids, this is a ‘hat’ block that requires a sequence of key presses to activate
the script to which it is attached (e.g. ‘up, right, down, left’) a fun idea, but essentially useless - why use
it when you can just click the ‘hat’ block to activate the script, unless you can cunningly hide the ‘Makey
Makey’ script - perhaps hidden behind a large floating comments call-out box.
The ‘AI Service’ extension (from Baidu, Inc.) was visible in the extensions centre earlier in the year.
Now, at the time of writing, this it has only just been activated for use in beta format - it says that it is
currently only available in China (& much of its feedback only appears in Chinese characters!). I
haven’t therefore experiment with it yet, but it looks both promising and exciting. Opening this
extension actually makes five new categories available: ‘Speech Recognition’, ‘Text Recognition’,
‘Image Recognition’, ‘Human Body Recognition’ and ‘Natural Language Processing’. - Wow!
N.B. Beware, the only way that any ‘Extensions’ that you have added to the 'Blocks' categories panel can
be removed is by reopening the 'Extension center' and then clicking the ‘Delete’ button below each
individual ‘Extension’ pack. If you wish to clean up mBlock 5’s available block categories panel by
deleting more extensions, it becomes a rather tedious task to reopen the 'Extension center' each time
since it closes after each deletion.
The principles are identical, so you can try whatever you want here, and since you are not
communicating with mBot, you can’t wreck anything, and you only need to save these project files if
you really want to.
My demonstration exercise shown below gets the default sprite ‘Panda’ to walk on to the screen and say
something. I used this exercise to encourage Emma to understand the programming techniques of
Scratch immediately after she had gone through the ‘Blockly’ based scripting exercises on her tablet.
The thought process (the basic algorithm) for this sequence is as follows:
Move Sprite to Move Sprite a Change the Wait a Move Sprite a Change the Say
‘Stage Left’ bit to the right Sprite image bit bit to the right Sprite image Hello
Open mBlock and choose the ‘Sprites’ tab (note that the block categories and the blocks themselves
change when you switch tabs). Drag the required command blocks from the ‘Blocks’ area to the
‘Scripts’ area as shown in the diagram below and slot the blocks together in the order shown on the right
of the diagram:
If you make a mistake, you can click the right button of your mouse and choose ‘delete’ from the drop
down menu to zap an errant block.
You can also choose ‘duplicate’ from the right-click menu too, so try duplicating the purple ‘next
costume’ block after you have dragged the first one across (because you need two of these) - leave the
duplicate at the bottom of the ‘Script Area’ until you need to drag it into place - duplicating blocks or
groups of blocks is very a useful trick to learn. You can either click the green flag on the top of the
screen (below the panda) to let mBlock run your programme or you can click the ‘Hat’ block at the top
of your script. Clicking here is OK - but it is essentially a bad habit - which sadly I still mostly do!
You will also see the green flag below the stage light up when it is clicked, and the red stop button dim -
note too that the red stop button lights up again when the code completes and the programme stops.
Try adding a second sprite - anything will do. If you click on the new sprite, you will see no script in the
‘Scripts’ area but if you click back on the Panda sprite you will see your block script once again. This
little experiment will show you that scripts are indeed attached to individual sprites. You can have many
sprites in a project, and you can have many scripts (or none at all) attached to a sprite.
Try clicking on the ‘Hat’ block at the top of your sequence of blocks, hold down your mouse key and
drag your blocks left from the scripts area towards the two sprite icons showing in the sprites pane on
the left of the screen. When your cursor is over your newest sprite, the sprite icon will gain a blue
background and ‘wobble’ a bit from side to side, let go of the mouse button and you will see that you
have duplicated your set of scripting blocks and now both sprites have the same programme attached to
them - try moving your new sprite by running the programme - you could also try modifying it so that it
is slightly different to the script attached to ‘Panda’.
You have just learned how to duplicate scripts; and moving scripts this way is a very a useful trick to
learn.
With a new (out-of-the-box) mBot, you have the following DEVICE programming options:
You can approach your programming journey any way that you like, but it’s a good idea to start your
mBot scripting adventure with some simple linear sequence scripts programming mBots output devices
(using no loops or control structures). I got Emma to create scripts to play a sequence of sounds with the
buzzer and flash the LEDs. The simple exercise shown on the next page is based on what she did.
Programming using the ‘Devices’ tab of mBlock 5 and using the ‘Scripts’ area on the right side of the
screen is easy. The code is ‘live’ and it can communicate with mBot as soon as it is created. You don’t
need to upload anything into mBot, which if it is connected to your computer by Serial cable or by
Bluetooth or by Wireless will follow the instructions in your programme as soon as you tell it to run
using the ‘Green-Flag’ (‘start’) button.
You can and should however ‘Save’ your programmes frequently so that you can reload them back in
to mBlock 5 at any time (so you don’t have to create them again). See Chapter 17 re. saving your
programmes (pages 152 and 153).
Here are some suggested programming experiments to explore each of mBot’s input and output devices:
1. Using output from mBots LEDs & Buzzer (light & sound).
2. Using the keyboard to control mBots movements & programming the IR Remote.
3. Using input feedback (distance), (line following) & (light).
4. Using feedback from logic & maths functions.
Simple linear scripts to control mBots LEDs & the Buzzer (light & sound):
In this exercise you need to experiment with the following two blocks.
And the one that enables mBots on-board Buzzer to play sounds:
The other three ‘bubble’ windows in the block shown at the bottom of the previous page require three
typed inputs to control the ‘colour-mix’ of the intensity of the light components (red, green and blue).
Sadly, mBot does not have any capability, in its own right, to play recorded sound files. The only way
that mBot can generate sound output is by using the onboard piezo buzzer to play a specific tone.
Since I learned to programme Clive Sinclair’s ‘Spectrum’ in the early 1980’s, programming pitch
changes for mBots buzzer recently has given me a real sense of déjà vu! To operate the buzzer, you just
choose the note that you want in the block ‘play note’ - or you can, if you really want to (and know how
to) add numeric values of frequency and rhythm.
The ‘Audio Player’ extension in mBlock 5 can play audio files, but only through Makeblock’s own Me
Audio Player (an acousto-optic output device with a built-in voice decoding chip). Sadly, this seems
hard to source; and apart from being included in a newly released (and expensive) ‘Talkative Pet’ add-on
pack is not available as a stand-alone item in the UK.
Rather than specifying frequency it is usual to set notes with normal musical notation which you choose
from the first drop-down menu window of the ‘play note’ block. The notes are written as C, D, E, F, G,
A and B. followed by a number, 2 to 8, which specifies the number (in scientific pitch notation - low to
high) of the available octave that you wish to use (there are actually seven and a bit of these - the same
number of octaves as a standard piano).
N.B. Middle C is the fourth C key from the left on a standard 88-key piano keyboard. It designated C4
in scientific pitch notation (however in MIDI, Middle C is note number 60).
You can also establish the duration (beat or rhythm) of the note in the second ‘bubble’ window, but you
cannot programme sustained notes (the period of time during which the sound remains audible and
overlapping with other notes).
You just click in the ‘bubble’ window and type the duration of
the sound you require e.g. enter 1 and the beat will last for one
second.
You need to be aware that if you write scripts to output sounds from mBot (such as playing a long note
or a short tune) then this will always stop the execution of further scripting code until the note or tune
completes. The mCore board will execute the task in a such a way that nothing else happens until it the
tone finishes playing, and this is known in computing as a ‘blocking task’ where your script is blocked
waiting for the task to complete. This will also disrupt any feedback polling loops in your scripts so if
you have, for example, programmed mBot to play a sequence of notes in response to being triggered by
a specific input, then mBot will not be able to look or ‘poll’ to see if a button has been pressed or what
the latest value returned from the line follower etc. may be until the ‘blocking task’ of sound generation
ends. A glitch like this may cause mBot to go out of control.
I’m not a musician, so I’ll leave this section here, but you might want to experiment more.
Emma liked the following ‘Two-Tone Horn’ sound effect, simple but fun - you may want to try it too:
To be able to use robotics programming blocks, you MUST be on the ‘Devices’ tab and here you will be
able to create a simple set of programmes in the ‘Scripts’ area that will allow you to control your robot
yourself for the first time. You only need to make one script to start with by using the ‘Events’ block
‘when (space) key’ pressed and then adding to it, the ‘Action’ block ‘move forward at (50)%’. Edit the
hat block by selecting the ‘up-arrow’ choice in its drop down list of options and then edit the stack block
bubble to set 40% power. Duplicate this script four more times and position them in the ‘Scripts area as
shown below:
Edit each script in turn until all five match the scripts above. The ‘Cap’ block ‘stop (all)’ is a ‘Control’
block. Remember as always to CONNECT mBot to mBlock 5. You will now find that you can use the
cursor keys on your keyboard to control mBot - but be prepared to hit the space bar to stop!
For the first time you can make mBot move or stop with a control programme that you have written.
For Info.: In mBlock 3 there used to be both the ‘when (space) key
pressed’ hat block and it’s opposite, a ‘when (space) key released’
hat block.
A rather more advanced version of your keyboard mBot controller is shown on the next page. You
might want to attempt this too. Don’t panic, it’s not that complex but will develop some further skills.
It essentially requires two things, a ‘Variable’ called ‘POWER’ needs to be created and the ‘Makers
Platform’ extension needs to be loaded so that you have access to the ‘DC motor’ blocks (as
demonstrated on the next page).
Click on the ‘Variables’ button in the block categories and then click on the ‘Make a Variable’ button.
A little window will open asking you to type in a ‘Variable’ name so type in ‘POWER’ and leave the
radio-button set to ‘For all sprites’ and then click the ‘OK’ button. In the ‘Variables’ menu, under the
‘Make a Variable’ button you will now see the name of your variable created as a ‘Reporter’ block
together with four more new blocks ‘set (variable name) to ()’, ‘change (variable name) by ()’, ‘show
variable (variable name)’ and ‘hide variable (variable name)’.
If you later make more variables, then they will also be shown in a vertical list under the ‘Make a
Variable’ button and their names can be chosen in the stack blocks described above by clicking on the
little ‘drop-down list’ arrow next to the existing variable name in the block. Remember to make sure
that you are on the ‘Devices’ tab and that you have added the ‘Makers Platform’ extension and then
create all of the scripts shown below:
You should be able to see how they work since they are very similar to the simple keyboard control
scripts that you have just experimented with and which are shown on the previous page. You can set the
speed for the ‘DC motor’ blocks by setting a new value in your ‘Green Flag’ initiated ‘POWER’
variable.
N.B. 50% is good, 35% is about the lowest that you can go without stalling and 100% is naturally the
fastest speed. You should also be able to understand the sequence of lights added to each controller
script. Note too that there is no block to turn LED lights off (but why not?) so to do this all input values
need to be set to set to zero (0, 0, 0) = ‘Off’.
You hardly need to make this script since your little IR remote already works
(unless you have uploaded something into mBot’s flash memory and no longer have
the out-of-the-box default functions loaded!). But it’s not a bad idea to go through
this short exercise to try to understand how keys on
the IR controller can be programmed to pass
commands - any commands to mBot.
Try it - however, be aware that you can only programme these four direction keys when you have the
‘Devices’ tab selected; and only when you are in ‘Online’ mode.
Whilst experimenting with this, I particularly wanted to get the ‘COG’ key in the centre of the four
direction arrows (which incidentally in the ‘Boolean’ block menu is called ‘Setting’) to work. It looked
so useful as a potential ‘stop-all’ key, but full programming of the IR key controls only works if your
control scripts are uploaded into mBot’s flash memory to replace its default settings.
This is a little too advanced for now, but the programming codes shown below are those returned when
the corresponding buttons are pressed on the IR remote control but these key codes only work if any
script using them is uploaded into mBot and run in ‘Offline’ mode.
A B C D E F ˄ ˅ COG ˂ ˃ 0 1 2 3 4 5 6 7 8 9
69 70 71 68 67 13 64 25 21 7 9 22 12 24 94 8 28 90 66 82 74
About mBots senses, its Eyes & Ears; and using input feedback (distance), (line following) & (light):
mBot has sensors that it demonstrated for you when you operated it with the Infra-Red remote control
unit (which incidentally has a line-of-sight range of approximate 10M). The IR sensor on the front of
the mCore board is the first of mBot’s sensors receiving signals from the IR remote enabling you to
control mBot manually.
The second sensor, also on the mCore board, is a light sensor (which looks like a clear glass bulb
sticking straight up out of the board). It is also located at the front of mCore between the two LEDs
(note - if these LEDs are activated and set to their brightest white light then this may affect the readings
from the light sensor by a minimal increase of perhaps just one or two). The light sensor feedback
values are theoretically in the range of 0 to 1000, however I have seen it reporting values of 1004 or
1005.
Sensors are used to detect events or changes in the environment and send information to the electronic
components of other devices. While a programme is running it is often required to collect real-time
sensor values to help understand the environment e.g. light, sound and distance values.
Data values that may change during the execution of a programme are known as ‘Variables’, whilst data
values that stay the same during the execution of a programme are known as ‘Constants’. You need
something called a ‘Variable’ to store and display values from sensors. Giving variables sensible names
helps when polling information from them via your scripts (and your scripts become much more
understandable too).
If you create a script with a ‘Variable’ set inside a ‘Forever’ loop you can see real-time feedback values
from sensors such as the on-board light-sensor - try moving your hand over the top of the mCore board
to see the value fall. If the ambient light is not stable (e.g. from a fluorescent lamp source) you cannot
see the rapid change of sensor values very easily, so a ‘wait’ block can be added to a simple script to
reduce the speed of change in the variable’s value which you will then be able to see clearly.
I have not yet really found a use for light-sensor feedback although I guess that it could be used to turn
on LED lights as darkness falls (very much like the common occurrences of ‘security-lights’ around a
house or garden). A control programme can store variable values e.g. the range of expected data
(highest and lowest acceptable levels and what action to take if they're exceeded). A continuous
(forever) process of such data analysis is called a feedback cycle.
Sensors are used to measure physical quantities such as distance, temperature, light, pressure, sound, and
humidity. They send signals to the processor on the mCore board to interact with programmes that you
can write to make control decisions.
A security alarm system, which may have an infrared sensor which sends a signal when the beam is
broken. A heat-sensitive sensor in the corner of a room may detect the presence of a person (by using
mBot’s ultrasonic sensor you can try something similar to both of these). Temperature sensors can be
used to control the heating in a building. Magnetic sensors can be used to detect metal and can be
placed in roads to monitor traffic flow.
Data transmitted from sensors (such as pressure, light, sound and temperature) is known as analogue
data. However, computers can only work with digital data. An interface or analogue to digital converter
(ADC) is needed to convert the analogue data from the sensors into digital data that the computer can
process and mBot has one of these too.
After the on-board sensors mentioned on the previous page (and more importantly perhaps) mBot has
two ‘add-on’ input sensor modules as part of its default components: one to sense distance using
ultrasonic feedback to let mBot avoid obstacles; and the other to sense the contrast between a light and a
dark surface for its line-following mode.
The aim of the simple exercise outlined below is to get mBot to move forwards and stop at a
predetermined fixed distance from an obstacle that it detects with its ultrasonic sensor and when / if the
obstacle is removed, it continues to run forwards. The ultrasonic sensor module mounted on the front of
mBots chassis has two protuding tubes that look a bit like ‘eyes’. One of these ‘eyes’ transmits a high
frequency wave that bounces off any intervening surface or object and the wave returns to be received
the other ‘eye’. This type of sensing is known as echo-location (so they are actually ‘ears’!). The sensor
is set by default to measure distances in centimetres.
N.B. If you later make more variables, then they will also be shown in a vertical list
under the ‘Make a Variable’ button and their names can be chosen in the four stack
blocks described above by clicking on the little ‘drop-down list’ arrow as shown in
the script on the left.
If you click on the ‘Green Flag’ (or the ‘Hat’ block at the top of the script) mBot should run forward
until it is less than (or equal) to 10 centimetres away from an obstacle - try using your foot! If the
obstacle is removed, it will continue to run forward - but it will not stop - something that we will solve
next! Make sure that you save your project with a suitable filename.
The script now needs to be improved by changing the method of ‘looping’; so you need to modify it to
look like the script shown at the bottom of the page. This will allow you to press key ‘A’ (Manual
Mode) on your IR remote control to exit the programming loop and stop mBot whenever you want to.
I also suggest that you practice your block nesting skills here too. You don’t have to do this bit, but you
could modify the ‘set - Distance - to ()’ stack block in your original script to measure in millimetres
(using my method for doing this as described in detail in Chapter 9 (page 41) and shown again below:
mBlock 3 had a very useful ‘key (space) pressed / released?’ hexagonal ‘Boolean’ block enabling any
specified key on your keyboard to action / exit from decision making scripts. In mBlock 5 this has now
been replaced by two ‘Boolean’ blocks ‘when onboard button (pressed / released)’ and ‘IR remote (A)
pressed’ ; neither of which are, I believe, quite as useful!
Start to modify your simple sensing script by removing the looping ‘Control‘ block ‘forever’ and
replacing it with a ‘repeat until’ looping ‘C’ block - this will also loop forever; but only until something
that you have specified becomes true (like specifying pressing the ‘A’ key on the IR remote).
This modified script is not perfect, but it is indeed a much better solution to the original problem, and
you should have learned a little more from this experiment; so save your modified project once again -
but this time with a new name.
Another (slightly more advanced) Control Programme for mBot - the Line-Following Sensor:
mBot already has something similar to the programme you are about to create
built into its memory; but the aim of this exercise is to understand how mBot
can follow the black line of the figure-of-eight paper track supplied. When the
light energy from the emitting LEDs in the line-following sensor reflect off a
surface, information about the reflective properties of that surface is transmitted
back to mBot and the lighter the colour of the surface, the more light is reflected
(in comparison to the amount of light that is reflected from a dark coloured
surface).
Each blue light is a good indicator of what each LED pair can ‘see’. If both
LEDs are ON, they indicate that there are high levels of reflected light and are
over a light surface - the sensor module returns a value of ‘3’. If both are OFF
this indicates low levels of reflected light (they are over a dark surface) and the
sensor module returns a value of ‘0’.
The sensor uses its LEDs to constantly check the contrast between the surface
below each of them - if the left-hand blue-indicator light on top of the module is
OFF it shows that low reflected light (a black surface) is detected on the left
pair of LEDs and the module will return the number ‘2’.
To complete this
exercise, you need to
create a variable called
‘Line_Sensor_Value’
which will hold one of
four values (0, 1, 2 or
3) which are returned
by the sensor.
This will define the new stack block shown here on the right:
This ‘Devices’ tab exercise does introduce you to defining a ‘My Blocks’ block for the first time and the
script for your self-defined ‘Follow_Line’ block is shown below.
As you can see, the ‘Follow_Line’
block has four simple ‘If ‘decisions
- if the first is not true then the next
is tried and so on. Since the
‘Follow_Line’ block is inside a
forever loop then this is a constant
circle of reading the sensor
feedback value and reacting in
response to the numeric value
returned. You will also need to
make two separate, simple and very
short ‘start’ and ‘stop’ scripts too
(see below):
N B. The code blocks (shown above left underneath the ‘Follow_Line’ hat block) could all be inside the
forever loop of the primary ‘when (up arrow) key pressed’ ‘start’ script (instead of the ‘Follow_Line’
block shown) but using a self-defined block, as you can see, is a much neater way to do it.
Note too that it is often not a bad idea to have several shorter, isolated (and easier to test) sequences of
blocks in the mBlock 5 ‘Scripts’ area. Using ‘My Blocks’ is a good way therefore of achieving this.
Sensors are used to detect events or changes in the environment and send information to programmes or
directly to other electronics devices. When the ambient light around mBot’s on-board light sensor
changes, then, if you create a suitably named variable and make it visible on the mBlock 5 stage it will
show feedback of real-time readings.
This exercise will show how to capture light sensor values and display them as real-time feedback.
Other sensors usually use the same method to collect and display data too.
The on-board light-sensor returns values in the range of 0 to 1000. If mBot is exposed under sunshine
then it probably returns values > 500, in evening light, perhaps only 0 to 100 and indoors (under
artificial lighting) perhaps values between 100 to 500.
You can test this for yourself - so try experimenting with the following ‘Devices’ tab script. You will
need to create a variable called ‘Light_Level’ to display feedback and the ‘Forever’ block will ensure
that the light sensor is constantly updated to display real-time values.
If the ambient light is not stable (e.g. from a fluorescent light), then you will see a
rapid change of sensor values, so if necessary add a ‘wait’ block anywhere inside the
‘Forever’ loop (set to about 0.5 secs) which will reduce the speed of the value
changing in the variable and you will
be able to see the feedback values
rather more clearly.
Try moving one of your hands close to the top of mBot’s mCore board. The 'Light_Level' variable will
drop (into the mid-300s). If the light level drops below 900 the on-board Buzzer will stop playing a
tone. Raise your hand a little and the 'Light_Level' value will rise, and the note will resume playing
when the value rises over 900.
You could try other simple experiments in the same vein too.
I found that when I began messing about using simple scripts with Emma that the following two
exercises were a great success - so much so, that we returned to them several times to create new and
improved versions. Look out for them again when we come to programming the add-on LED panel
(see Appendix 1 on page 184).
N.B. Scripts like those shown below (with no robotics commands) can be written either on the
‘Devices’ tab or on the ‘Sprites’ tab, since both will return their feedback to variable monitors on
the stage.
For this you need a variable called ‘Random_Number’ to hold and display a random number and I added
two more variables called ‘Text_1’ and ‘Text_2’ to hold some extra feedback in the form of text
messages displayed on the stage - a much neater way of providing textual feedback than getting a sprite
to give out messages using the ‘say’ or ‘think’ blocks from the ‘Sprites’ tab ‘Looks’ blocks. You could
use just the ‘Text_2’ feedback Variable if you want to (& the “Hey Emma” bit could have been added
into this variable too).
The script and the displayed feedback variables (shown above right) are both very self-explanatory. The
script sets a ‘Random_Number’ variable between 1 & 6 using the ‘pick random’ block from the
‘Operators’ block group and then concatenates the result with the second text variable.
My ‘set (Text_1)to ()’ stack block just returns whatever text is entered into it. The set ‘Text_2’ stack
block uses a ‘join’ block from the ‘Operators’ block group to concatenate the text “You have thrown a ”
with the ‘Random’ Variable.
Every time you click the ‘Hat’ block, a new random number between 1 and 6 will created and the
message will display the new number (although if it generates the same number you will not see a
change).
Setting the variable monitors on the stage to have no labels actually looked much better and Emma liked
having a digital ‘dice’ quite a lot, so we then devised the next experiment to create again using random
numbers. This exercise is described on the next page.
This exercise uses the same variables as those shown in the previous exercise but with the addition of
something new - a ‘List’. To make a list, click to select the ‘Variables’ block group and then click on
the ‘Make a List’ button.
A little window will open (just like the one for making
Variables) asking you to type in a name for the list - call it
‘Useful_List’ (so original !) and click the OK button.
The name that you gave to your list will now become a
‘Reporter’ block with an assortment of eleven useful
blocks below it (see the diagram on the right):
Click the little plus (+) button again and a second slot will
appear - enter “Paper” and then create a third slot and
enter “Scissors”.
That’s it, the new list is complete.
You can re-size the window by
clicking and dragging the bottom
right-hand corner and you can click
and drag anywhere else on the
background to move and reposition the window anywhere on mBlock’s ‘Stage’. If
you click in any of the list slots, you can edit the contents or click the (x) button to
delete the slot and you can also right-click and ‘hide’ the list from view if needed.
The ‘length’ number at the bottom of the list you will have probably worked out for yourself is the
number of entries in the list.
You can use a list like this in a very similar way to a ‘VLOOKUP’ table in Excel by return anything
stored in the second column windows by specifying a number in the first column windows. A specified
number returns output from the second column of the row specified by the number.
Reopen your simple ‘dice throwing’ script (the previous exercise) and save it with a different filename.
You can now modify it to look like the one shown at the top of the next page.
You should be able to understand how this works. A random number (1,2 or 3) is generated and the
‘Reporter’ block ‘Random_Number’ (let’s say it’s a 3) is used as the lookup number in the ‘List’ - row 3
returning ‘Scissors’. Save your basic game project with a sensible filename.
Emma thought that pressing the space key as well as using your other hand to make your chosen game
shape wasn’t very good, so we decided to modify and improve this script a little more by involving
mBot.
This modification made the game much more realistic to use with mBot as the opponent and Emma
really did like this version - but watch out (as with the basic dice-thrower exercises) there are yet more
enhanced versions of this to follow as this book progresses!
Save your project once more with another (different) filename to the exercise at the top of the page.
Using these blocks, sprites can display meaningful text and sensor information; but who really wants the
default sprite to be saying or thinking feedback from mBots sensors ! ? ! If you create a blank sprite in
the costume editor, to use for text output using these blocks then the bubbles rather eerily appear out of
thin air. Surprisingly, the ‘say’ and ‘think’ blocks can display a lot of text - approx. 480 characters (24
characters per line x 20 lines).
A modification wish: If a new Scratch block could be created, perhaps called ‘label’ and with a simple,
non-specific outline (such as a round-cornered rectangle) then it would be much more useful than the
‘say’& ‘think’ call-out bubbles and this would be VERY useful. Creating an additional block such as this
might, I guess, be fairly easy for the MIT group (or Makeblock) to programme and add to the ‘Looks’
blocks collection?
You can if you want to, use the ‘text’ tool in mBlock 5’s costume editor to make labels of any size and
shape that can be positioned anywhere on the stage. The fonts are rather limited and there is no
justification or emphasis like Bold or Italics, but you can colour text in any shade you like & you can
cheat a bit by duplicating a text sprite, changing its colour and then positioning it over the top of the first
to create a drop-shadow effect.
To do this you need to create an animation, using a graphic image of a dice showing every possible
combination of spots on the dice. You need therefore six matching images showing each of the different
spot permutations. You could take photos of a real dice to do this (or source dice-face images from the
internet) but it is much better to create your own drawn graphics. (See Chapter 14. This provides a lot
of information about how to draw and create sprites). To use graphics on the stage that you can
manipulate via scripts, you need to be on the ‘Sprites’ tab.
Animations in Scratch programming are achieved by changing a sprite’s costume, so the basic
programming principle here is if ‘Random_Number’ = 1 then show costume ‘1’.
I already happened to have a set of dice images (drawn in ‘Word’) at least twenty years ago to illustrate
random numbers in ‘Excel’. Making them is not difficult - but do refer to Chapter 14 for guidance. I
based my drawings on ‘Isometric Projection’ a technical drawing way of showing pseudo 3D images
with all horizontal lines being drawn at 30˚ and all vertical lines remaining at 90˚.
To make the top of a cube, draw this ‘diamond’ using the ‘Freeform Shape’
tool. Duplicate it twice and rotate one duplicate by 60˚ and the other by -60˚
30˚ and position them as shown on the right.
Add an ellipse to fill the top of the resultant ‘cube’ and duplicate it twice too. Rotate
one duplicate by 60˚ and the other by -60˚ and position them as shown here. You now
have now created some very useful basic isometric rectangles and circles for 3D work.
There are nine positions where a spot can be found on each face of a dice,
so divide up the top face of your cube with more 30˚ (isometric)
construction lines as shown in red on the left. Group the set of red lines
and rotate them and add them to each face. Shrink your three ellipses to a
suitable spot size and then duplicate and position them as shown on the left
so that there are nine spots carefully positioned on each of the three visible
faces of the cube. Delete the three sets of red temporary construction lines.
Group everything that you have drawn so that your nine-spot dice cube
becomes one object. Duplicate it five times (so that you have the six dice
face permutations that you need and then (only then) delete unwanted spots
on each face of each of the cubes to leave them as shown below.
You may wish to colour your dice before you make your five duplicates - I did
exactly that, as you can see on the right, making each of the ‘diamond’ faces a
colour of your own choosing and then making the spots a contrasting colour. To
get the effect of reflection on the three internal edges of the dice I added a line
matching the colour of the spots in each direction and added them to each group.
Once I had completed my six dice drawings in ‘Word’ I converted them into .png files so that they could
be added to my ‘Sprites Library’ in mBlock 5 (see Chapter 14 on pages 89 to 96 for more on this).
Back in mBlock 5 I could now add the six dice images (named ‘1’ to ‘6’) as individual costumes of a
sprite which I named as ‘Dice’ - once again such an original choice of name!
I decided that I would start afresh with totally new scripts for this project rather than modifying the very
simple dice thrower script described on page 67.
I created a new backdrop for the stage by going into the graphics editor and filling the whole of the
‘paint’ area with a shade of dark-green (Hue: 30, Saturation: 100 and Brightness: 40) to emulate green
baize. My ‘Dice’ sprite looked good on this.
My concept was to have one dice being rolled from the top of the stage (the starting corner being chosen
at random); the sprite starting small and tumbling to its final resting place in the opposite corner at the
bottom of the stage with the sprite costume being selected by the random number ‘Operators’ block we
had used earlier. To do this neatly and clearly I decided to use self-defined ‘My Blocks’ to maintain
clarity.
Start by creating
the four ‘My
Blocks’ hat blocks
shown on the right
and then create the
primary ‘start’
script using the
‘when (space) key
pressed’ ‘Hat’ block shown on the left of the diagram. Next you need to populate the four self-defined
hat blocks. The top two of these are shown below:
You can see here that the ‘Position_Dice’ block throws the ‘Random_Number’ and chooses the costume
matching it. You will also notice that I have added a ‘play sound’ block which you can omit if you wish
whilst you are creating this project. The short sound that it calls is a recording that I made of dice being
shaken in a soft backgammon dice cup. It’s worth the effort, because this does create the illusion that
dice are about to appear! The ‘Throw_Direction’ block uses another random number ‘Operators’ block
to choose from which side of the stage the dice will be ‘thrown’.
The ‘Throw_Direction’ decision then calls one of the two left /right ‘dice-animation’ script sequences
(shown at the top of the next page). They are essentially identical, so make one first and then duplicate
the blocks to add to the second. All that you need to do is reverse all references to the x position in your
duplicated blocks making positive numbers negative and negative numbers positive.
Save this project with a suitable filename; and there you have it, real moving graphics on the mBlock 5
stage. Emma was really impressed by this version and although the graphics creation methods were a bit
beyond her she did understand the programming including the dice ‘tumbling-in-perspective ‘sequence.
Playing ‘realistic’ Rock, Paper, Scissors against mBot using the mBlock 5 stage
This is a little harder to achieve than the graphical dice project above. First, you need three images of
the required hand shape. You could take photographs of someone’s hand for this or get images from the
internet (but be careful not to infringe copyright). I went for the option once again of drawing them in
‘Word’ using the same the ‘Freeform Shape’ tool to create simple thick outline drawings (using ‘Edit
Point’ nodes to adjust each line. These three Rock, Paper, Scissors drawings are shown at the top of the
next page:
The image on the left shows the edit points (or nodes)
around one of my three ‘hand’ drawing.
At the top of the first finger you can see the selected
node has two levers which use ‘Bezier Curve’
attraction to smooth the curve passing through the
node. This node is a ‘smooth’ point which works like a
see-saw - if one lever goes up, then the other goes
down which affects the path of the line through the
node.
I needed to add a new block to replace them (as shown here above). This was an ‘Events’ block
‘broadcast (message1)’ - This broadcast block is a VERY IMPORTANT addition, but more about this
on the next page.
I then switched to the ‘Sprites’ tab. Remember, this is where you can programme sprites on the stage.
Just like the dice images in the last exercise, I added my three
drawings as individual costumes into a new sprite which I
called ‘Hand’; each costume appropriately being named as
‘Rock’, ‘Paper’ and ‘Scissors’.
The last three blocks show the hand-shape costume that has
been chosen, wait for two seconds and then hide it again.
Emma now not only had mBot sensing her hand movement in front of the sensor, but mBot responded
by showing its own hand-shape choice on the stage; and this looked so good when run in ‘Presentation
Mode’ too!
The clever bit of ‘magic’ here is the hat block ‘when I receive (message1)’. This accepts the signal
‘broadcast (message1)’ sent from mBot via the script on the ‘Devices’ tab and that allows the contents
of the variable ‘Random_Number’ to be used by a script on the ‘Sprites’ tab to choose which graphic is
displayed on the ‘Stage’.
To summarise, scripts written on mBlock’s ‘Devices’ tab CAN send data as part of a broadcast
message to be received by scripts created to receive them on the ‘Sprites’ tab for use on the stage.
This this such an important concept to grasp that I have explained it in some considerable detail in
the next chapter.
If you have completed the last two graphics programming exercises then you have done very well.
… In Scratch (and therefore mBlock 5 too) the 'Green Flag' is a programming feature that
will, when the icon below the stage is clicked, set a chain of events in motion starting all
scripts in a project that begin with the ‘when (‘Green Flag’) clicked’ hat block.
You may see that all scripts attached to a sprite thus hatted (and clicked as
described above) will be illuminated, for the period of time taken to run
each script. This shows that they are being run and this is useful for
instance if you want to populate variables with data at project-start-up. A
‘Green Flag’ icon click runs all such scripts in a project in parallel; whilst
a ‘hat’ block click only runs the script that is clicked. As mentioned on
page 53, clicking on the ‘Hat’ block at the top of any script on the stage is something that you may well
have got into the bad habit of doing in some of the earlier exercises in this book? - I did & still do!
As your projects get more complex, you must however use the ‘when (‘Green Flag’) clicked’ block with
some care. My recommendation is not to use more than one ‘Green Flag’ hat block in a single project
since this can create errors that are difficult to diagnose; these errors often only appearing occasionally
with every other start of the project and such errors can cause timing issues.
If at all possible, therefore, use just one ‘Green Flag’ block followed by
‘Broadcasts’ to activate all other scripts that need to run when the project begins.
When creating a project, it is fully possible to avoid using the ‘Green Flag’ at all if you design it to be
started by a key on the keyboard being pressed or a sprite on the stage being clicked.
N.B. If you are running a project ‘Offline’, then pressing the ‘Enter’ key on a keyboard will start all
'Green Flag' scripts. If you shift-click the 'Green Flag', then ‘Turbo Mode’ will be activated; whilst a
‘Control-click’ will mute the project so that a project cannot produce any sound. The opposite of the
'Green Flag' icon is the ‘Stop Sign’ icon and if you click it, then a project will be halted
and stop all scripts. If you add the ‘Cap’ block ‘Stop ()’ to a script and set it
to ‘all’ then this has the same effect as the ‘Stop Sign’ icon, halting a project
and fully-stopping all scripts.
Apart from the basic dice-thrower exercise on page 67, all of the programming exercises demonstrated
so far have involved mBot and thus the need for robotics programming blocks. It has been mentioned in
every exercise too that you must therefore be on the ‘Devices’ tab to access these specific blocks. The
‘Sprites’ tab is very much for manipulating graphics on the mBlock 5 stage (its called ‘Scratch Stage
Programming’) and as we have demonstrated, the stage can be used to display variables data and
feedback data from mBot in monitor windows - see Chapter 14 (page 86) for more on these; but on the
face of it, not very much more is easily possible - so how do you achieve anything else?
“ Eureka! ”
When I found out about ‘Broadcast messages’ and how they are meant to work in mBlock 5 it was
indeed a revelatory experience; and in programming terms a very ‘Damascene’ moment!
Once you realise that mBlock 5 has in reality two different Scratch programming sections to use (with
mostly different blocks in each of them) it is easy to see where you are going to create ‘Device’ scripts
that control mBot and ‘Sprite’ programming scripts that can be used to animate realistic graphics.
The clever bit is to understand how ‘Broadcast messages’ can be used to transfer data-on-demand
between the two to enable you to display sensor feedback from mBot visually on mBlock’s ‘Stage’ (in
any way that you want) and also enable you to click meaningful sprites on the stage to send control
commands back to mBot.
Makeblock seem to want you, the user, to find out about programming their devices yourself so when a
new (completely different) application like mBlock 5 comes along then to where do you turn? There are
no books available on mBlock 5 yet! The ‘GitBook’ is rather brief and there is not a lot of really useful
mBlock 5 content on Makeblock’s excellent Forum as far as I am aware.
However, in late July (2019) I still seem (on this guidance front)
to be “ploughing a very lonely furrow’ ! *** (but see the next page) ***
In Scratch programming, scripts are written to programme an individual sprite and are available to that
sprite only; and that script is only visible in the editor if that particular sprite is selected. In ‘Scratch
Stage’ programming, broadcast messages are used to activate scripts attached to receiving sprites from
any broadcasting script attached to any other sprite.
In mBlock 5 scripts are also used to programme devices so why not, I thought, try this method to
broadcast and receive between a device and a sprite - and it worked - YES, it’s good to talk!
… and there is no other way to get a device and the stage to talk to each other
(apart from using - if you really have to, the Upload Mode Broadcast Extension).
*** I originally wrote this chapter in 1919 - in January 2020 I just happened to revisit the generally
useful ‘GitBook’ mBlock 5 Help Document which can be found at:
https://www.mblock.cc/doc/en/
This had clearly been updated since the last time that I visited it (- it was dated October 2019) and under
‘Device Programming Basic Operations’ / ‘Interact with Sprites’ I found the following section:
“In mBlock 5, the script editing area for devices is separate from that for sprites. To
implement the interaction between devices and sprites, for example, enabling a sprite to
tell the value measured by the ultrasonic sensor of mBot, you need to use the broadcast
functions to transmit and receive messages (instructions) and values.
In the Live mode on mBlock 5, devices and sprites that support broadcasting can
communicate with each other by broadcasting and receiving messages, and therefore the
interaction between devices and sprites can be implemented”.
M
SEND Broadcast RECEIVE
RECEIVE Messages SEND
Representations of switches etc. can provide real-time controls for mBot too!
Broadcasts are a little tricky but are nevertheless a very useful technique to learn. In Scratch, you use
broadcasts to pass messages among sprites and Scratch has no limits as to where a broadcast can go.
Broadcasts are a simple but very powerful way of implementing event-driven programming and
broadcasts can be used to branch a single sending script into many receiving scripts, or to close many
sending scripts into a single receiving script.
The ‘Broadcast’ block sends messages which are used to control programme
flow and any sprite (including the sprite that broadcast the message) within a
project can listen for that message and respond accordingly. The stage can
send and receive broadcasts too and you can have as many ‘chained’
broadcasts in a project as you like.
You must therefore learn to handle the development of projects running broadcasts with some care to
avoid errors & subsequent mBlock 5 crashes (and consequently you MUST progressively save and
backup your projects frequently too).
When using broadcast messages to communicate between a physical robotics device and computer
graphics on mBlock 5’s stage you need to initially prepare the way for any device data that needs to be
transferred, enabling it to be stored in sensibly assigned variables using scripts written on mBlock’s
‘Devices’ tab and then sending that data as part of a broadcast message to be received by scripts created
to receive them on the ‘Sprites’ tab.
Got That ! ? ! - Time to move up a gear and into some very advanced work …
If you click on the ‘Code’ option within the app. it loads ‘Blockly’ (v. 0.8.5 EN) which Makeblock have
developed to teach the basics of coding using drag ’n drop block programming When loaded
(according to its icon label on my phone) it seems however to be called just ‘mBlock’. Blockly dates
back to 2011 and whilst not quite the same visually, does resemble Scratch coding enough to move any
knowledge gained within the
app. across into programming in
mBlock 5.
Awesome!
The ‘Create’ component of this
software allows users to make
their own control interface by
dragging any of the components
available in ‘Design’ mode on
to the main work area from a
library of components on the
left of the screen.
Using your own layout of switches, power-sliders and direction controllers here; together with
simulated seven-segment LED displays (of four digits) which impressively show real-time numeric
feedback from your device’s sensors is so easy when using this component of the app.
Conversely, mBlock 5 has NOTHING to enable realistic robotics control / feedback interfaces to be
shown on the stage display and certainly nothing like the wonderful stuff that Makeblock have
developed for the Android app. mentioned above. mBlock 5 sadly has no specific device-supporting
sprite libraries which can be added to the stage to produce really useful displays.
Why hasn’t Makeblock developed something similar to this app. as part of mBlock 5?
It would have been really good if Makeblock had created a specific library of such stuff for
robotics work rather than just the existing mBlock 5 libraries which are composed of typical Scratch
‘artwork’. It begs the question, why use mBlock 5 for what can be routinely done in Scratch 3?
The backdrop and sprite libraries in mBlock 5 are typically Scratch and
are NOT robotics oriented at all.
As I have mentioned before, it took me quite a long time to realise that mBlock 5 has in reality two
different Scratch programming sections to use (with mostly different blocks in each of them). Getting to
grips with this basic understanding of mBlock 5 makes it much easier to see where you are going to
create ‘Device’ scripts that control mBot and ‘Sprite’ programming scripts that can be used to animate
realistic graphics.
Creating block scripts on the sprites tab is generally referred to as ‘Scratch Stage Programming’ and the
blocks available for programming sprites are essentially the same as the blocks used in mBlock 5’s
natural parent Scratch 3. But what about ‘hybrid’ scripts - how can you control a robotics device and
interact with graphical output to the Scratch ‘Stage’?
Graduating from mBlock 3 (where there weren’t ‘Device’ or ‘Sprite’ options as separate entities) there
were only one set of programming blocks to deal with and the ‘Robots’ category of blocks seemed to be
just tacked on to the end of the usual set of Scratch programming block categories; rather like
permanently added ‘extension’ blocks. If you wanted to programme mBot then you just used this set of
blocks with the occasional foray into the other block categories to add something useful to the ‘Stage’.
Such hybrid scripts worked very well as long as you didn’t want to upload them into mBot’s flash
memory.
As a new mBot owner in 2018, I wanted to programme mBot as a robotics device. So other than
developing robotic control scripts with a little hybrid ‘Scratch Stage Programming’ added, I did not
develop any of the programming skills that advanced ‘Scratchers’ tend to have; and so even after using
mBlock 3 for a year, I was, at the start of 2019 (and switching my allegiance to mBlock 5) not an
enthusiastic or skilled ‘Scratcher’, only understanding what I need to do to enable me to programme a
robotics device such as mBot.
It took me even longer to understand that the really clever bit of Scratch programming
know-how is to understand how Broadcast Messages can be used to transfer data-on-
demand between ‘Device’ scripts and ‘Sprite’ scripts. This enables you to display (in any
way that you want) sensor feedback from mBot visually on mBlock’s Stage and also enables
you to click meaningful sprites on the stage to send control commands back to mBot.
Why does Makeblock not make this vital piece of knowledge clear? As far as I
understand from the excellent Makeblock support team, they are happy to resolve
problems relating to their hardware or software but are not there to provide specific
guidance on programming techniques.
The purpose of my book is to experiment with, understand, and explain all things mBot and I ask
myself why (?) when it comes to graphical on-screen feedback from robotics devices, has Makeblock not
given much thought to mBlock other than enabling you to develop scripts to control robotics devices
such as mBot using the programming blocks (and extensions) available on the ‘Devices’ tab.
Why is there nothing robotics related for the ‘Sprites’ tab? Numeric feedback from device sensors and
data held in named variables (created by you) can be shown using ‘monitor readouts’ added to the
‘Stage’; but not much else is easily possible under the devices tab since anything further than that
necessitates switching to the ‘Sprites’ tab. Writing simple control scripts for mBot on the ‘Devices’ tab
is very straightforward (after using mBlock 3) but when it comes to the ‘Sprites’ tab, you need to
develop much more skill as a Scratch programmer.
After many years of teaching, I am supposedly good at creating realistic graphics so ...
… I decided that I needed to emulate the fine example of the Android app.
described earlier and create my own comprehensive sprites library of robotics
control components and several simple multipurpose backdrops on which to
display them.
When creating useful stage-interface screens to work with mBot or any other robotics device you first
need a suitable backdrop where you can then place switch or button sprite graphics which may need to
have several ‘when this sprite clicked’ scripts attached to them.
It makes sense to write a simple one-line script for every sprite that you create to enable it to reposition
itself ( that is, if you happen to drag it by mistake!). Then switch or button sprites require a script to
animate any audio-visual effects needed to suggest realism when clicked (moving either up-and-down or
in-and-out etc. together with a suitable sound effect). Finally, these sprites require a script to a carry-out
the required action that you want to take place when the graphic is clicked (but this could be part of any
audio-visual script).
Images created for the stage (whether backdrops or sprites) need to be carefully thought out and well
planned. Because of the very nature of the Scratch stage’s display resolution any original artwork that
you create must be the of the highest quality possible to meaningfully represent and manipulate
feedback from a device such as mBot.
Scribbling outline design concepts down first and creating simple sketches of your ideas is sensible.
Creating an evaluation / planning algorithm (considering perhaps the specific implications of Who?
What? Why? Where? and When?) for any potential display layout is almost certainly a good idea too.
But what method should you use to create the meaningful sprites and backdrops required? The obvious
choice is the costume editor in mBlock 5. In it you can create all of the images for any project that you
wish to make. It is quite powerful, versatile and generally so much better than that it was in earlier
versions of the software and for many users it is now quite possible to generate reasonable looking
images, either as bitmap paintings or vector based (editable / movable) drawings; but it has a major
drawback ...
… If you draw anything in the costume editor then there is NO ‘SAVE TO COMPUTER’ option
(although mBlock 5 can since its recent update export sprites as .sprite3 files).
You can’t download anything created in the mBlock 5 costume editor into your own filing system for
future use and neither can you add them into the backdrop and sprite libraries like you can with graphics
created outside the application. You can however upload your own graphics (both backdrop & sprite
images) into mBlock 5. There are occasions when simple sprites can (and should) be created in the
costume editor; labels for the desktop are a good and effective example; but the only sensible option is,
for the most part, to create both backdrops and sprites outside of mBlock. Such files can then be
uploaded into mBlock’s backdrop and sprite libraries for repeated future use.
When creating both Sprites and Backdrops, I always use the vector-graphics
precision, complex colouring options, 3D extrusions and overall editing
versatility of Microsoft Office; usually using Word.
My first drawing test in Word was to emulate the buttons from the Android
app. My drawn copies of these are shown here on the right:
You can easily capture anything you draw in Word as a bitmap (by screen-grabbing it, using Windows
‘Snipping-Tool’) and after a little more editing you can then upload such image files into mBlock’s
Sprites or Backdrops libraries for further use in new projects.
If you don’t have Microsoft Office, then the free alternatives ‘OpenOffice’ and ‘Libre Office’ do work as
substitutes very well.
For the reasons outlined earlier regarding the inability to save and reuse images created in the editor this
is not my preferred method; but as demonstrated, it is possible to create a reasonable quality 7-Segment
LED graphic. A ‘screen-grabbed’ image of this, drawn in the Graphics Editor, is shown in the
illustration at the bottom of the previous page.
In the editor, always position a sprite in relation to the default center (x, y) position; either leaving your
drawing evenly spaced around the center of the sprite or (for a specific reason perhaps) with the x, y
center position of the sprite set at one corner or another significant feature of the image.
If you must use the editor, then it will help considerably if you learn several basic vector drawing
concepts. Clicking the pointer icon together with holding down the shift key enables you to add
individually drawn vectors together and group them to become one object. You can drag the pointer too
to create a ‘marquee’ box around a collection of shapes for grouping purposes. With an object selected,
pressing the Tab key will step you forward through object sequences, whilst holding down the Shift key
and pressing the Tab key will step backwards – this is in the order of object creation NOT in the current
stacking order.
Holding down the Shift key whilst drawing will also constrain a line to be either horizontal, vertical or at
45˚. Using Shift when drawing ellipses or rectangles will produce equal growth of the shape in x & y to
produce circles and squares. Using the Alt key whilst dragging with the mouse pointer will grow shapes
from the centre outwards and a combination of the Shift & Alt keys together will constrain shapes to
remain both equal in x & y and grow (or shrink) from the centre all at the same time.
This can be summarized as follows. First, you create a precision graphic using Word’s powerful vector
drawing tools and then capture an image of it using the Windows ‘Snipping Tool’ and then finally save
that image as a .jpg file with a suitably descriptive name (.jpg & .gif are the only save options with the
‘Snipping Tool’). At this stage the .jpg image that you have captured will be surrounded by the
background of your Word page (usually white by default) and this colour needs to be made transparent
for sprites to work effectively.
To do this, you need to load the .jpg file you have captured into a graphics editing package such as
Photoshop and use the ‘Magic Eraser’ tool to set any unwanted white background into ‘transparent’. (If
you don’t have Photoshop, then free alternatives such as ‘Irfanview’ and the ‘GIMP’ will convert .jpg
files to .png format and both can save the transparent attribute).
A transparent background in Photoshop has a tiny checker-board pattern (just the same as the
background shown in the mBlock graphics editor diagram on the previous page). Zoom in to check the
edges of the shape very carefully and erase more background if needed.
Use the ‘Clone Stamp’ to edit individual pixels if further work is necessary and to touch-up any
damaged areas especially around the perimeter of the required shape. You need to spend some care and
time using both of these tools to prepare a sprite since any background un-erased will show when the
sprite is used in mBlock 5. To retain the transparency around the sprite when it is uploaded into mBlock
5, you must save the file as a portable network graphics (.png) format file - this is the only graphics file
that mBlock will accept.
An updated version of mBlock 5 was released in early July 2019 with a modified user interface which
generally has been improved. On the ‘Edit’ page, the ‘Scripts’ area is larger and there are now just two
choices to adjust its size (and therefore the ‘Stage’ size too). A sad loss from the ‘Menu’ bar however is
the button giving instant access to ‘My Projects’. To choose a project you now have to (marginally
more slowly) select ‘Open’ from the ‘File’ menu to access the ‘My Projects’ screen; but this is actually
OK once you get used to it.
mBlock’s stage backdrop size still retains the somewhat old standard-screen proportion of 4:3 (and a
paltry resolution of 480 x 360 pixels).
How can computer graphics in the 21st century be of such low resolution?
Both the ‘Edit’ page and full-screen ‘Presentation-Mode’ seem to be sharper brighter & clearer. Sadly,
the area surrounding the ‘Presentation-Mode’ screen is no longer dimmed down (to nearly black) as it
was in version 5.0.1. Note the full-screen ‘screen-grab’ above showing the limited size and proportion of
the ‘Presentation Mode’ window on a modern widescreen monitor).
Making the surround totally black would have been a much better option. In the new release, the
surrounding screen is only slightly dimmed which does have the advantage of seeing a looping script
‘pulse’ etc. but on the whole it is not really a lot of use and as you can see, does distract from the main
event (the bit that you do want to see) the presentation screen in the centre. A second full-screen
‘screen-grab’ showing the new slightly
dimmed ‘Presentation Mode’ screen on v
5.1.0 is shown here on the left.
Data monitors such as these display values held in named variables that you have created. In mBlock 5
there are now monitors that can display device
sensing feedback in a similar fashion with their
screen output displayed in blue monitor windows.
Data monitors are useful when developing and testing projects but are rather ugly to look at; and as you
can see, increase in size dependant on the length of the variable (or sensor’s) name.
Note too that the monitor readout windows are marginally smaller if there is no data
at all stored in the variable and they do increase in length if more than four
characters are stored (as demonstrated on the diagram on the right). A double
mouse-click on monitors shown on the stage toggles in turn through each of three
different monitor readout variants. These variable monitor readout windows are
always orange in colour with a grey rim hinting at a recess.
As can also be seen on the presentation screen images on the previous page, I used three ‘large’ variable
monitor readouts - the ones with no name label (showing the numbers 1 and 4 and 8).
These large, label free, monitor windows are visually rather more useful, BUT they only remain in the
large setting state in the stage display as long as the mBlock 5 application is open. If you close and exit
mBlock 5, then saved projects lose their ‘large’ setting variable displays when mBlock is restarted and a
project reopened, reverting back to the default, standard size monitor (with their labels showing)
although they do seem to remember where on the screen they were positioned.
This seems to be a minor programming error from Makeblock here since large monitor readout settings
do save and reload correctly in Scratch 3 projects. This error was there in v5.0.1 and still exists in the
new update (v 5.1.0). Projects still do not remember which of the three monitor windows were last
active when they are reloaded in a new software session. They do remember where they were positioned
but they always default back to the named (labelled) monitor type. I quite like using them but sadly
(unless Makeblock correct this soon) this makes the use of large monitor readouts unusable in a project.
The third choice of variable monitor readouts is the ‘slider’ (an example of one of these is also shown in
the image on the previous page). This variant does have some uses, but in both mBlock 5 and Scratch 3
they are now limited to a range of 0 to 100 (unlike in its predecessor mBlock 3) where you had the
extremely useful option of being able to set your own min. & max. values for the slider adjustment of
variables.
N.B. All three variants of the variable monitor readouts mentioned above are hard to position accurately
on the stage backdrop because they can only be moved by dragging them with the mouse (there is no x
or y positioning for monitor windows like you can set for sprites). Tip: Create a temporary sprite with a
vector drawn horizontal (or vertical) line and use it on the stage to help align other sprites or monitor
readouts; and then delete (or just hide) the temporary sprite on completion. For info.: the ‘large’
variable monitor readouts (the ones with no name label) measure 62 x 36 pixels in size.
You may have noticed in the same screen-grabbed images shown on the previous page that it is
possible with the right know-how to create a seven-segment LED display monitor of your
own design using carefully drawn sprite costumes and some simple programming to match
sprite costume graphics to numbers held in data variables.
Seven-segment LED displays are commonly used in digital clocks & calculators etc.
Without the need to show any of mBlocks graphically limited monitor readouts on the stage at all, sprite
graphics that you create yourself allow you much more flexibility (in both size and position) when a
project requires you to echo the contents of stored variable or sensor feedback data. Home-grown high-
quality graphics used to simulate alpha-numeric data input or output controls does give to any project
shown in ‘Presentation Mode’ on the ‘Stage’ a very professional looking interface.
If you want to save & move your carefully crafted projects and libraries to another computer or other
storage device, you can - in a roundabout sort of way because they are all stored in the following path:
The ‘sprites folder has four .json database files (backdrops, costumes, sounds & sprites) and show as
thumbnail images of all of the graphics that you have created.
Files are shown in these library folders as thumbnails, but with unique names written in hexadecimal
code. The .json files seem to be an index of mBlock’s libraries of uploaded files.
You could, if you want to, just copy just the two ‘sprites and ‘projects’ folders to use elsewhere (on
another computer or as a backup archive) but you could also store the entire mBlock folder instead, as a
backup, if you think that you might need it.
N.B. Files loaded into a computer from the Cloud do not add their libraries to that computer.
New to mBlock 5 in the v 5.1.0 update (but already available in the launch version of Scratch 3) and a
massive improvement is the much needed ‘Export’ sprites facility enabling reuse of the block code and
multiple costumes for that sprite when uploaded into other projects. Any attached (or floating) comment
call-out notes remain attached to the saved sprite too.
If you right-click on any sprite (or the device icon in the ‘Devices’ tab) then ‘Export’ is an available
choice. This enables you to save a single sprite or device as a .sprite3 file. These can then be added
into another project by using the ‘Upload’ button in the sprites library.
N.B. A sprite containing block scripts uploaded this way is NOT however added into your ‘My Sprites’
library. If the uploaded .sprite3 file was a ‘Devices’ tab device icon, then it opens as a new device icon
on the devices tab (remembering which device type - mBot or Codey etc.) to which it was attached.
This is a very quick way to start a new project with some useful device stuff and sprites already in
place!
To create files suitable for uploading, I captured them straight from my Word page using the Windows
snipping tool; and to make sure that they were exactly the right dimensions I loaded each ‘Snip’ into
Photoshop and used the cropping-tool set to 480 x 360 pixels to crop them to an exact size and
resolution before resaving them as .jpg files.
I next created a similar backdrop in blue with white lines which I called ‘Blueprint’ and then eight more,
several of these making use of some of the different texture fills available in Word. I chose some of the
textures (like ‘Cork’ & ‘Papyrus’) because they were sympathetic to the orange shade of mBlock 5’s
variable monitors. But, as mentioned earlier, I am no longer using these monitors since projects
currently lose their ‘large’ setting variable displays when mBlock is restarted and a project reopened.
Don’t be daunted by this. It’s much easier and much quicker to complete than you would think, so just
be positive - but DO aim for a high-quality graphic EVERY time!
First, you need to make a master set (1 to 9 & 0) of LED digits - the method for drawing these is
described on the next few pages. Once you have these drawn and converted into .png files, they can be
inserted as costumes into a “digit” sprite and the sprite duplicated as many times as you need for
different monitors. Your original sprite can also be exported and reused over-and-over again in other
projects too.
Monitor windows of various proportions are also needed and then you can develop switches, sliders
indicator lamps, direction controls etc. etc. as you need them.
As mentioned earlier, is quite possible to bypass variable & sensor data being displayed in any of the
three monitor readouts variants described. It’s much better to display such data using LED type graphics
of your own creation; any size, any style, any colour, positioned accurately anywhere on the stage.
To create your own data monitors, you need to create individual sprites for digital ‘Units’ (or ‘Tens’, or
‘Hundreds’ etc.) with ten individual number costumes added to each sprite. Creating a set of ten LED
digit costume drawings initially seems to be a rather tedious to create, but the work is worth it when they
can be used over-and-over again. Also, and rather complex, (but nevertheless achievable) is the
programming required to match a sprite (and its costumes) to a digit stored in any variable that you wish
to display on the stage.
You can just type individual digits into a sprite in the costume editor (one costume each for digit 1 to 9
and 0). This is a very simple but effective method. You can also capture .jpg images of alphanumeric
characters in any font, style and colour too and these would also be quite suitable for many projects.
However, traditional seven-segment LED display characters look particularly good when showing
device feedback in mBlock 5, especially if they are placed in front of graphically drawn feedback
monitor windows on an equally carefully thought-out stage backdrop.
Real electronic LED displays are available in a variety of LED colours; most notably Green, Red,
Yellow, Purple & Cyan. The Scratch programming ‘change colour’ block can be used to change the
colour of any sprite and the ‘brightness’ of graphics can also be changed using the ‘change brightness’
block to simulate fading or flashing displays. Seven Segment Displays are still very common but are
now often superseded by 8x8 LED matrix displays or LCD displays which produce finer display
characters. LEDs are often in a proportion of 5:3 and typically slope by approx. 10˚ (italicised) but they
can be found as vertical digits too.
As shown in the diagram on page 83, it is quite possible to create these in the mBlock graphics editor;
this diagram shows that if you go to ‘Costumes’ and create (using vectors) a basic grid in a new sprite
and draw just one horizontal & one vertical segment of the seven segments required. You can then just
copy and paste each of these enough times to make up the seven segments required for the numeric digit
“8”. This is the first costume within a new sprite, so you need to simply name it ‘1’ (even though it
looks like an ‘8’ and then duplicate it another nine times in all to create a total of ten costumes for the
sprite & they should have been automatically named 1 to 10. Name the sprite itself ‘Digits’. Next, edit
each costume graphic in turn to delete the segments not required to create each number so that each
costume matches its name (& rename the last costume “0”).
As mentioned earlier too, using the Graphics Editor is rather pointless since any graphics created here
cannot be reused easily. It is therefore far easier to create much more precise LED digits using the
drawing tools in Word which can then be converted to the correct format and uploaded into your sprite
libraries.
Using Word to do this is much quicker than you would think since numeric digit “8”contains all seven
segments of a LED display and all the other number costumes can be made by duplicating this one and
deleting the segments not required for each number. (See the drawn diagrams on the next page).
First you need to first create a precision construction grid; eventually sacrificial, but nevertheless
important in developing an accurate technical drawing. Draw two (thinnest line possible) rectangles one
50mm x 30mm and the other 38mm x 18mm and middle them horizontally & vertically. Group them
together & make the line colour blue; these signify the outer and inner dimensions for your drawn
characters enabling 6mm thick individual segments to be drawn to create the component segments of a
LED graphic.
Draw a vertical red line, with its Height set to 60mm and then draw a
horizontal red line with its Width set to 35mm. Duplicate these lines five
more times to make six of each in all and position them on top of the two
rectangles as shown in the diagram on the right.
You need to set each group of three lines (both horizontal and vertical) to be
3mm apart in each direction. Use ‘Middle Horizontally’ and ‘Space
Horizontally’ to help you do this to the vertical lines and then use ‘Middle
Vertically’ and ‘Space Vertically’ for the horizontal lines. Finally group all
of the lines together and you can then, if you want to, delete the blue
rectangles.
You should by now have an accurately drawn red-line grid that looks like
the one shown above right.
To create the slightly more sophisticated italicised look (and this is the
style that I personally think looks best) you need to start by duplicating the
grid you made earlier; ungroup this duplicate grid and rotate all of the
vertical lines by 10˚. Regroup the new grid and it should look like the
diagram shown here on the left. You now have an upright grid and an
italicised grid for creating seven-segment LED graphics. Save your file.
Return to your original upright grid so that you can create the required
segments. To obtain greater accuracy increase the zoom factor of the Word
page so that your drawn grid fills most of your screen.
Select the Freeform Shape tool and click it in the centre intersection of the
topmost left-hand corner of your grid and draw a segment like the
horizontal one shown in the diagram on the right.
Next draw a vertical segment like the one shown below it.
This is the only digit you need to create to make a complete set of upright
number digits since it contains ALL SEVEN segments of the LED display.
All the other digits can be made by duplicating this one and deleting the
segments not required for each number.
To look like a real LED display, the segments now need to be separated slightly.
Leave the centre segment where it is and use the cursor keys to nudge the remaining
segments as follows:
This may sound quite a lot of nudges, but as you can see in the set of digits (on a
black background) shown below-right, the smaller the LED digit, the less noticeable
are the gaps between the segments.
It makes sense to shrink segment-separated (stretched) digits
back to their originally designated 50mm x 30mm size. Use
another temporary 50 x 30 rectangle to do this (see the
diagram above).
You don’t have to do this bit, but if you add a temporary construction line at the top and another one at
the bottom of the row of digits you will see that the vertical segments in the digits 1, 4 , 7 and 9 do not
reach either the base line or the top line (in reality, this is what would happen with the segments of a real
LED display). I am inclined to follow this principle, leaving the height of these segments as they are -
but you might wish to make them all the same height; so, just stretch each segment of these four digits
vertically to touch the construction lines (see above) and when this is done, delete the two lines.
The middle segment of this new digit can be copied from your vertical
LED drawing. Once again, use the Freeform Shape tool and create the
remaining six new segments as shown in the diagram on the left.
Modifying your drawn shapes using Edit Points is an important skill to master
too and do not be afraid of deleting a shape and completely redrawing it again
if any segment does not look right. Finally, remember to nudge the segments
apart and then shrink the group of segment-separated (stretched) digits back
to their originally designated size.
The outline of all of the drawn segments of my two basic green LEDs are set
to NO Outline and the flat-fill colour that I have used is demonstrated here on
the right. When creating these drawings in Word, the HSB colour fill settings
are: Hue: 85, Saturation: 255, Brightness: 180 and their equivalent RGB
settings are: Red: 100, Green: 255, Blue, 100.
However, when editing in Photoshop, colour fills are vastly different to the settings to those in Word
(described above) and different again in mBlock’s own graphics editor. Photoshop’s equivalent settings
to the shade of green I used in Word are: HSB Hue: 120, Saturation: 80, Brightness: 100 and RGB Red:
50, Green: 255, Blue: 50.
To create digits with transparent see-through backgrounds you do need to edit them in a graphics editor
such as Photoshop and save them as a portable network graphic (.png) file. This file type is commonly
used to store graphics for web images (where they always need to have a transparency attribute set).
You can see that in the image on the left that the
outer corners of the italicised LED digit that I created
look quite sharp and ideally should be radiused
slightly; but this would be hard to achieve using the
vector drawing methods described earlier. BUT - it
is possible to do this when converting the drawing
into a .jpg painting file which you can edit in
Photoshop.
These seemed rather more realistic than the flat-green early versions (although they look good too).
Using the Windows Snipping Tool, I captured each of these “8” digit drawings on their black
backgrounds in turn and saved them as .jpg files with a suitably descriptive name (remember, .jpg or .gif
are the only options).
I named each of these files Digit (italic) 8 and Digit (upright) 8. I then created two file folders called
LED Sprites (upright) and LED Sprites (italic) and moved each of my two newly created .jpg files into
their matching named folders.
In each folder I copied the original Digit upright / italic 8 file and pasted it back into the folder until
there were nine copies of the original “8” digit file in each folder. I then altered the name of each so that
the number at the end of each filename was from 1 to 0 (even though at this stage they all had the same
“8” graphic) and each one still with a surrounding background colour of black (which eventually needs
to be made transparent). To create this transparency, I loaded each .jpg file in turn into Photoshop and
used the ‘Clone Stamp’ set to mimic the black background and then painted-out the unwanted segments
for each digit.
When each number looked as it should (matching it’s file name), I switched to the ‘Magic Eraser’ tool
and used this to set the unwanted black background as transparent (the tiny checker-board pattern). I
used the ‘Zoom’ tool to check the edges of the shape very carefully and erase more background if
needed. Mostly this worked perfectly much of the time. I also used the ‘Clone Stamp’ again to touch up
any damaged areas especially around the perimeter of the required shape.
The Magic Eraser with its tolerance set to 40 worked well and I had very little further editing to do but
you do need to spend some care and time using both of these tools to prepare a sprite since any
background un-erased will show (annoyingly) when the sprite is used in mBlock 5.
After I had edited and saved each of my numbered digit images files in turn, I opened each folder to
check the thumbnails to see that I did indeed have a complete set of ten digit images (0 to 9). Finally, I
reloaded each .jpg file in turn back into Photoshop and saved each one as a .png (portable network
graphics) format file which retains the transparency attribute set of the sprite; and when each folder had
ten individually named .png files (each showing just a unique numbered digit image with no black
background) I no longer needed my original set of .jpg files, so I deleted them. You may not be brave
enough to do this, so do keep them in the folder if you wish to.
Next, I turned my attention to creating a sprite image for a monitor readout window that could be added
to a backdrop and positioned (in any size, anywhere). These needed to be effective as a realistic display
background for my 7-segment LED images. Unlike the black windows used in the Android app. I
wanted the look of a traditional LED display, a recessed dark-coloured window. To make these is very
simple, just a trick of effectively using light and shade.
Draw a Rectangle with round corners and duplicate it to make a second matching rectangle, the second
stacked on top of the first. Give the first of these a mid-range thin grey outline and set a Gradient Fill
for the shape - Linear 90˚ - dark grey at the top to light grey at the bottom. Give the second of these the
same mid-range thin grey outline and set a Gradient Fill for the shape - Linear 315˚ - dark-blue, bottom-
left to dark-green bottom-right. Reduce the size of the front rectangle slightly (equally in x & y) and
centre it horizontally and vertically on top of the first rectangle. The amount of reduction in size of the
top rectangle dictates the depth of the recess (see below).
Duplicate it again and reverse the shading of each circle - now this one
looks like a button that has ‘popped-out’. You’ve made rubber buttons!
Add text into the middle of each button. If you make a ‘Button’ sprite and
upload .png images of each of these drawings as costumes into an mBlock
5 sprite, you can then use the ‘When sprite clicked’ programming block to
change to the next (or previous) costume. You’ll need to create this
simple decision making script to make it work.
If you have tried this out then you will have created a realistic working
button - especially if you have completed the illusion with a suitable sound effect (‘click’) and you can
of course change the grey shades demonstrated above to any colour combination that you like.
Many other .png files with transparent backgrounds can be created using the methods described above. I
used to use these basic skills of manipulating light and shade a lot when I was teaching many years ago
to enthuse kids by getting them to make high-quality graphics which they learned to programme using
VBA (in Microsoft Excel).
In an advanced version of the graphics techniques shown above I used to use an exercise outlined briefly
at the top of the next page. This project was a graphical illusion, using ‘visibility’ to hide/show one
graphic at a time; clicking one graphic hid it and showed its opposite; just a simple on/off animation
trick. Kids reactions when the switch ‘worked’ for the first time (with a ‘click’ sound effect added) were
always amazing; “… I’ve programmed something that goes in-and-out of the screen - Wow!”
Shown below is the method for creating drawings of coloured indicator lamp ‘bulbs’.
4 circles =
PUSH
PUSH or or or
This Excel exercise was so simple, but how effective in developing an enthusiasm for programming and
for spreadsheets too (sneaky teacher!).
Two switch extrusions were positioned on top of each other (on a switch plate recess) and then one of
the two individual VBA subroutines shown was assigned to each of the rocker-switch drawings:
S
E
G
M RED
E
N START
T
L PURPLE
E
D
STOP
C
O CYAN
L
O
U
R
S GREEN
Design Requirements
for an mBlock 5 stage
‘Presentation Mode’
CONTROL INTERFACE
for an mBot robotics device
mBot mBot
Forwards Left
Directional mBot
Control Stop
OUTPUT
REQUIREMENTS
Speed
mBot mBot
Control Backward Right
s
Slider
Range: 50 to 250
(in increments of 50)
Digital
Monitor
INPUT Ultrasonic
REQUIREMENTS Sensor
Analogue
Meter
‘Power’
On / Off Digital
Clock LED
On / Off Colour
Changer
EXTRA
REQUIREMENTS Indicator
Lamps
Digital
Sensor Day / Date
On / Off On / Off
The clever bit is to understand how Broadcast Messages can be used to transfer data-on-demand
between the two to enable you to display sensor feedback from mBot visually on mBlock’s Stage (in any
way that you want) and also enable you to click meaningful sprites on the stage to send control
commands back to mBot.
By using your own graphics to create high-quality interfaces, feedback data from mBot can be
represented on the Scratch Stage in a variety of real-time digital, analogue or alphanumeric output
formats; and representations of switches etc. can provide real-time controls for mBot too!
My first complete development of a fully working Device / Stage Interface (shown above) is explained
in full detail in this chapter - however in reality each of the sub-component parts of my ideas were ‘test-
bedded’ separately first and then added together to form the complete project which relies on using pre-
prepared graphics uploaded into mBlock 5’s libraries. (See how to make these in the previous chapter).
Power
No Yes
Switch
ON
Stop All mBot LED Sensor
Speed
Controls Slider Switch
Yes Slider
available Available available
Left, Right,
Available
Green, Cyan,
Up, Down & 50, 100, 150,
Purple, Red
Power Lamp Stop 200 & 250
& Yellow
turns Green
Sensor
Switch No
Movement
Clock, Sensor & Speed Colour ON
Button
Speed Monitors Selected Selected
Clicked Ignore
‘Illuminated’
Yes
mBot Lamp mBot Speed LED
turns Green Adjusted Display
Adjusted Sensor
Lamp turns
mBot moves in Green
Direction
Indicated
mBot
Transmits
Stop Button Sensor
Clicked Reading
Once I had an
idea of what
output and input
tasks were
required for a
fully working
interface, I had to
consider the
visual look that I
thought was
needed.
I then to make sure that I developed the required stage graphics for both the display output of feedback
and switch / button / slider input (see pages 90 to 96 of Chapter 14 for more on this). All of these
graphics had to then be uploaded into either my mBlock ‘backdrop library’ or ‘sprites library’.
I decided that the shiny metal plate background that I had created would be my final backdrop for the
project although initially I used my graph-paper backdrop to help me align and position the individual
graphics on the stage. Knowing from early tests that I could get the value from mBot’s ultrasonic
sensor stored in real time in a variable that could be used by graphics on the mBlock stage, I had in mind
that I wanted both digital feedback and an analogue meter of some kind with a pointer fluctuating as the
sensor values changed. This sensor displays distances of up to approx. 4M (4000mm) so I need a meter
capable of displaying 4000 divisions in a semi-circle.
My aim was to also have a four-way direction controller for mBot and a ‘stop’ button too. I also
planned to add two moveable sliders, one for altering mBot’s speed and another to change the colour of
any 7-segment LEDs used.
To go with the first of these sliders, I thought that a speed monitor would be good to show the speed set
and after much deliberation decided that adding the day, date and time might be a nice feature and as a
demonstration of how to add these to a project. I also planned to demonstrate a couple of different
methods of producing ‘clickable’ buttons.
If you want to try making a similar interface, start by opening a new mBlock project file and then follow
the sequence of steps beginning on the next page. N.B. You will need to use your own (previously
created) graphics libraries to achieve this.
Uncheck all of the tick boxes next to each variable name to hide their stage
monitors. This is now a good time to save your project with a suitable filename.
Click the down arrow to access the drop-down list and click on ‘new message’.
Type in the complete set of (20) messages shown on the left one after another
(these are also listed rather more clearly below):
Save your project again (you do need to do this on completion of every step).
Step 3: - Now is a good time to test some of the Messages defined in Step 2 earlier by broadcasting them
from the ‘Sprites’ tab to the ‘Devices’ tab to send control commands to mBot, so delete ‘Codey’ and
choose mBot as a new device and remember to go to the ‘Devices’ tab and click connect!
If you haven’t done so already, click on the ‘Devices’ tab. See the diagram below. Here you need to go
to the ‘Events’ section in the ‘Blocks’ area and drag the ‘when I receive’ hat block shown above onto the
‘Scripts’ area on the right of the screen. You need five of these in all and you can either drag more
across or duplicate four more from the original one you dragged across first.
Go to each hat block in turn and click the down arrow to access the list of messages - choose
‘Stop_Motors’ as the message for this block.
Next go to the remaining four hat blocks in turn and set the message for each as follows,
‘mBot_Forward’, next block ‘mBot_Backward’, next block ‘mBot_Left’ and finally ‘mBot_Right’.
They now need control (‘Action’) blocks adding to each of these hat blocks as shown in the diagram
above. The first (‘Stop_Motors’) block is straightforward. Choose the ‘stop moving’ block from the
‘Action’ section of the blocks menu and drag it across to connect with the hat block.
It is possible to use from the ‘Action’ section, the ‘move forward at power()’ block for the four
remaining hat blocks; changing ‘forward’ to ‘backward’, ‘left’ or ‘right’ as appropriate. I decided
however to use the rather more sophisticated action blocks (shown in the diagram above in Arduino
house-colour, sea-green). These are taken from the ‘Makers Platform’ extension, and if you haven’t
added an extension pack into mBlock before, is not a bad thing to try this right now.
Leave the default power setting at (50%) for now. Eventually, but not yet, you will need to replace this
percentage in all of these control blocks with the variable ‘mBot_Speed’. This is needed when you have
some way of changing the value of that variable (by adding and programming a slider control graphic).
To test that mBot can indeed be controlled from the ‘Stage’ using sprites is actually very simple. All
you need are five ‘broadcast’ blocks taken from the ‘Events’ section of the blocks menu.
Do note that blocks in the ‘Events’ section are identical in both the ‘Sprites’ tab and the ‘Devices’ tab
whilst other block categories are not.
Give each of these ‘broadcast’ blocks message names matching the ones that you used for the five hat
blocks on the devices tab. You will note from the diagram shown below that I arranged each of these
blocks with the ‘Stop_Motors’ block in the centre with forward at the top, backward at the bottom and
left and right positioned accordingly. NO (green flag) hat blocks are needed above these to make this
work.
Just try clicking each broadcast block in turn to activate it. If mBot is connected, then it will move
accordingly and prove that sprites scripts can control devices!
Step 4: - I used my ‘Graph-Paper’ backdrop to lay-out the twelve principle sprites that are needed on the
interface. This layout is shown at the top of the next page. It’s not a bad idea to add these major
components now rather than add them one at a time later on as you start to write scripts for them. Doing
this now is a bit of a confidence boost too - it looks like you are beginning to have a working project at
last. Despite grumbling earlier about the resolution of the Scratch stage, I cannot fault the way that
mBlock 5 handles the resizing of sprite graphics with no apparent lack of quality!
First, I positioned the backing plate of my mBot Direction Controller (which I named ‘Backstop’) and
the Analogue Sensor Monitor on the centre line of the stage, setting the X & Y coordinates of these to
0,-80 and 0,90 respectively. My graphics also needed to be reduced in size to fit the stage layout; I set
the Size of both the backstop and the monitor window to 50. You will need to choose your own Size
settings (a percentage of actual image size) to match your own graphics. N.B. The X & Y coordinate
positions of all of my sprites (apart from the analogue pointer mentioned earlier) are set to the centre of
each graphic.
Sensor Monitor
(Analogue) Sensor Monitor
(Digital)
Speed
Slider
LED
Colour
Slider
Activate
Activate Sensor
Interface
Speed
Clock Monitor
Monitor (Digital)
Next, I added the digital sensor monitor window at coordinates 125,150 and set its Size to 28. This was
followed by the longer thinner graphic for the digital speed monitor window set at coordinates 190,-138
with a Size setting of 24. The final monitor window was an even longer and thinner graphic for the
digital clock window, which was set at coordinates -165,-138 with a Size setting of 50.
Finally, I added the last indicator lamp graphic (to show when mBot is activated) and set its X & Y
coordinates to 125,-138 with a Size of 25 and last of all I addded my two individual switch graphics
above the other two indicator lamps seting the Power On/Off (Start/Stop) switch at -122,40 - Size 60
and the Sensor On/Off switch at 122,40 - Size 50. N.B. We will add the day/date ‘engraving’ and other
descriptive ‘engravings’ to the interface later! Delete the default ‘Panda’ sprite and use the ‘add new
Sprite’ button to add your own praphics to create something rather similar to this. Its once again time to
save your project file as usual to ‘My Projects’ in the ‘Cloud’.
Its not a bad idea at this stage to make a backup file too, by saving a copy to your computer rather than
just to your instant-access ‘My Projects’ storage area. Do this backup on a frequent basis too.
Step 5: - Return to the Devices tab. It’s time to add the remaining device scripts that you need here. So
far you have created five scripts that you can eventually call using messsages to control mBot (you
tested these by clicking them in Step 3).
The first block in this script ‘Digits_Shown’ calculates and stores the number of digits that make up that
whole-number and the next three blocks then calculate the individual digit that needs to be displayed
when the sensor’s value is broken down into hundreds, tens and units - simple really. Finally, it
broadcasts a message to update the digits displayed on the stage and this all happens in real-time as the
sensor value fluctuates.
The third and final addition to the scripts needed here on the ‘Devices’
tab is shown on the right. You now need to make this too - it resets all
of the display digits on the stage to 0 and it then broadcasts the same
message as used in the previous script (‘Update_Digits’). N.B. Even
if some scripts broadcast message names where there there is not yet a
receiving script to action, this is not a problem. As is now usual at the
end of a step sequence, save your project file.
Step 6: - It’s time to think about creating scripts for each of your
sprites, but first, some notes about the mBlock sprites list in general.
This project requires a rather alarming 49 sprites in total (but 16 of these are text that can be quickly
created as needed using the mBlock graphics editor). Of the remainder, several are duplicates; notably
the fourteen 7-segment LED digits and the three indicator lamps. You should have already added the
first twelve principle project sprites (created in Step 4 earlier) and you should be able to see all of these
in the ‘Devices’, ‘Sprites’ & ‘Background’ categories panel on the left of the ‘Edit Page’ below the
‘Stage’.
You can alter the width of the stage area on the mBlock ‘Edit Page’ and this affects how many sprites
are displayed across the ‘Devices’, ‘Sprites’ & ‘Background’ categories panel below the stage. The
default width will show three sprite icons across this panel on the majority of desktop monitors, but only
one or two sprites wide on most laptop displays. My monitor displays seven rows of sprites without
having to scroll down the list; but a disadvantage of having a lot of sprites in a project, is that the new
sprite button is always last in the list and any new sprites are added at the bottom of the sprites list too.
Sprites can however be dragged and repositioned in this list very easily and placed in any order, but it
makes sense to have the ones you are currently writing scripts for near the top of the list and therefore
always visible; so getting used to dragging them into a sequence that suits you is not a bad idea.
One of the two sprites I suggested adding first was the analogue sensor monitor.
This in itself is purely a background sprite graphic added to provide realism for a
moving pointer rotating in response to feedback from mBot’s ultrasonic sensor. As
such, this technically does not need any scripts written for it in the ‘Scripts’ area
when it is the currently selected sprite (highlighted in blue with the ‘delete-me’ cross
on its top right corner. BUT - it does make sense and good practice to add a script
such as the one shown below on the right to EVERY sprite that you create.
This script stores the coordinates that you set when you positioned the sprite
accurately on the stage. x: 0 (exactly on the vertical centre-line) and y: 90
(90 pixels up from the horizontal centre-line of the stage). The ‘hat’ block
at the top and the ‘Motion’ block below it clearly indicate that if that sprite
is clicked (& inadvertently dragged on the stage) the sprite will always
return (go to) its home coordinates position and move behind everything
else. When you are experimenting with a project on the edit page then
moving sprites by mistake often happens; but do note that in full-screen ‘Presentation Mode’ it is not
possible to drag sprites (although you can click them to activate scripts).
Step 7: - It would be no bad thing at this stage to test the ultrasonic feedback from mBot and then test an
analogue pointer on top of your meter graphic (the analogue sensor monitor). Start by switching to the
devices tab and clicking the ‘Connect’ button at the bottom of the left hand panel of the edit page.
Choose the ‘Sensing’ section of the ‘Blocks’ area and check (tick) the second block choice from the top.
This will turn on the following stage monitor:
This shows (if mBot IS connected!) the feedback from the sensor - try moving mBot left and right to see
the display change in real time.
Choose ‘Sensor_Pos’ as the name inside the block and type ‘1’ to
replace ‘0’ in the little window at the end.
To activate it you need to click it somewhere that doesn’t action the name or the contents of the window.
Try clicking somewhere near the left-hand end of the block over the top of the word ‘set’. The block
will ‘blink’ and you will see that the ‘Sensor_Pos monitor window on the stage will change from ‘0’ to
‘1’.
The ‘Sensor_Pos’ variable is a simple binary ‘1’ or ‘0’ (on/off) switch eventually controlled by the
power switch sprite on the interface - for now, you have had to
manually provide the ‘1’ in the variable to allow the next test to
proceed. Try clicking the hat block at the top of the script you created
on the devices tab (this is shown here on the right).
If you look at this script you will realise that it does need ‘Sensor_Pos’ to equal 1 to proceed. Then it
takes the sensor feedback and rounds it to remove the decimal places after the integers and displays this
in the ‘Sensor_Value’ variable. Clicking the hat block should now show whole numbers fluctuating in
the ‘Sensor_Value’ variable monitor on the stage.
Pres the red ‘stop’ button below the stage to halt the script and save your project file.
Step 8: - To see this script fully working, you need to add a new sprite into the project - the meter
pointer described earlier on page 100. I drew mine in Word using just a filled red circle and a thin
red triangle added over the top of it; but this is such an easy thing to create, so you could just as
easily draw this as two vector shapes in mBlock 5’s costume editor. (See the diagram on the
right). The important thing about the pointer is its x, y position in the editor. It must have its
pivot point over the centre of the editor screen! Set your own size for this to match the size of
your meter graphic. The pointer needs three scripts creating on the sprites tab with the pointer as
the active sprite.
These three scripts are shown at the top of the next page.
Try running the ‘Poll_Sensor’ message by clicking the ‘hat’ block on the devices tab again. You should
now see the meter pointer fluctuate in response to mBot’s sensor. After this test, you can uncheck the
variable stage monitors to hide them and also uncheck the ‘Sensing’ monitor too.
Success, another confidence-boosting milestone - you now have graphical feedback from mBot!
If you have a problem with sprites not being visible despite the ‘Show’ sprite
switch being set to ‘on’ (e.g. the pointer sprite is behind the monitor sprite) then
use the two ‘Looks’ blocks shown on the right to change the layer (stacking)
order of your graphics. Remember this tip - at some point in the making of your
project you will certainly need it! Save your project file and back it up again.
Step 9: - The first sprite that I added in step 4 was the backing plate for the mBot
Direction Controller (which I named ‘Backstop’). This is shown here on the
right and is the next thing that you should select so that you can then add the
two following scripts to it:
The left-hand script of the two scripts shown at the bottom of the previous page repositions the sprite if
necessary (as discussed in step 6 earlier), it then simulates a switch by using the sound effect ‘Click’ and
dimming the graphic briefly (so simple, but very effective). You will need to find a suitable sound file
for this (online perhaps where you could search http://soundbible.com/ for something suitable). Finally,
this script broadcasts the message to stop mBot. The second script, on the right of these two scripts
essentially switches an indicator lamp from green to red (or vice-versa) to indicate that mBot has
stopped or started.
Step 10: - It makes sense to add the four direction controlling arrow sprites
into your project next. Add an up-arrow (for forwards) at the top of the
backing plate, a down-arrow (for backwards) at the bottom and left and
right-arrows aligned with each other on either side of the backing
plate (for turn-left or right). Each of these needs to be positioned
precisely and sized to suit, so I set their coordinates as follows:
To do this you need to make the backing plate (stop button) your active sprite by choosing it in the
sprites list so that the two scripts you created earlier are visible in the ‘Scripts’ area. Make sure that you
can see your four direction-arrow sprites in the sprites list too by scrolling it up or down it as necessary.
Click the left-hand script of the two showing in the ‘Scripts’ area and drag it to the left. Keep dragging
across the ‘Blocks’ area until your cursor is over the sprites list. As you move across individual sprite
icons in the list, any icon under the cursor will rock slightly (or ‘wriggle’) to indicate that it is ready to
receive what you are dragging across. Let go of the dragged script when you are over the forward-
direction arrow sprite and it rocks from side-to-side. Click on that sprite to make it active and you
should see that the script that you dragged across has now been copied into it. Go back to the backing
plate (stop button) sprite and click and drag in the same way the second (right-hand) script across to the
forward-direction arrow sprite icon in the sprites list. Make this sprite the active sprite again and you
should see (but not very clearly this time) that the second script has also been copied; but has been
dropped on top of the first script. All you have to do now is drag the top script sideways slightly to
expose the first script and then reposition them neatly side-by-side. Repeat the process of copying the
two original scripts by dragging them to each of the other three direction arrow sprites. N.B. All of that
script copying & repositioning is much quicker to do than it seems in the lengthy description above!
You should now have the same scripts in both the backing plate (stop button) sprite and in the four
direction arrow sprites so you need to go to each of these four in turn and modify the blocks highlighted
to match the scripts shown below and on the next two pages. Note that you do need to delete the three
‘Looks’ blocks ‘go to (back) layer’ from each of these copied scripts.
First, here are the two scripts that you need to modify for the ‘move-forwards’ arrow sprite:
Delete go to back
layer from here
Next, here are the two scripts that you need to modify for the ‘move-backwards’ arrow sprite:
Delete go to back
layer from here
Next, the scripts that you need to modify for the ‘move-left’ arrow sprite:
Delete go to back
layer from here
Delete go to back
layer from here
Make sure that mBot is still connected. If not, go to the ‘Devices’ tab and click the ‘Connect’ button.
You can now click your controller arrows on the interface and mBot should respond and change
direction with each click.
To make these scripts work you may need to set the ‘Sensor_Pos’ variable to 1 again (like you did in
step 7 to test the ‘Poll_Sensor’ broadcast) but you should by now be more-than satisfied with your
project since you now have both sensor feedback and directional control and have demonstrated that
two-way communication between a device and a stage interface is possible.
If you have achieved this, then very well done so far. Save your project file and back it up again too.
Step 11: - Buoyed up by the progress of your project so far, it’s time to think about digital feedback on
the your stage interface. In step 4 I suggested that you added the digital sensor monitor window at the
top right side of the interface (at coordinates x: 125,y: 150).
Click on this sprite in the sprites list and (if you haven’t done it already) name it ‘Sensor_Monitor’ .
It is here that you now need to add hundreds, tens & units digits to represent the LED feedback (in
centimetres)from mBots ultrasonic sensor.
N.B. You have already written a script on the ‘Devices’ tab to broadcast this data.
You now need to create a new sprite with ten individual costume graphics (1 to 9 and 0) so click on the
new sprite button at the bottom of the sprites list to enter the ‘Costumes’ library’. If necessary, upload
all of your digit graphics into the ‘My Costumes’ library first and then open from that library the number
‘1’ 7-segment LED (.png) file that you created using my instructions in Chapter 14 on pages 90 to 94).
Name this sprite ’Sensor_Units’ and set its coordinates to x:150, y:150 and size: 15.
You should now see your LED digit nicely positioned in the monitor window at the top of the interface.
Click on the ‘Costumes’ button at the bottom of the ‘Edit Page’ (next to the sprites list) to open the
costume editor and name this first costume as ‘Digit_1’. The grey strip between the costume editor
window and the stage / sprites list panel is the panel containing the list of costumes available to the
sprite currently selected.
At the top of this panel you will be able to see your ‘Digit_1’ graphic (and this will also be displayed in
the editor window too). At bottom of the costumes panel is a little blue icon of a cat’s head and the
words ‘Add Costume’. Click here and it will take you back to the costume libraries.
The second script shown on the previous page is made up of five simple ‘if / then’ decisions which
reflect the position of the slider button on the LED colour backplate.
N.B. Once you have added the first of these five ‘if / then’ blocks (and added the completed green
‘Operators’ block and the purple ‘Looks’ block to it, you can duplicate it four more times and change
the colour effect number and the switch value number for each ‘If’ decision in turn.
A switch value of 5 sets the LED to yellow, a value of 4 to Red, a value of 3 to Purple, a value of 2 to
Cyan and a value of 1 returns the colour change to 0 (reverting the LED to its original colour, Green).
Without the slider switch values being set you can’t see the results of these changes by testing this script
yet; but, if you want to see what they look like, then find the ‘set (colour) effect to ()’ block in the
‘Looks’ menu, type in one of the values above and click the left-hand end
of the block (over the word ‘set’) and you will see your 7-segment LED
graphic in its monitor window on the stage change colour.
That’s quite a lot of work that you have just added, so it makes sense to save your project file once
again.
Step 12: - You now need to add the remaining two digit sprites; ’Sensor_Tens and ’Sensor_Hundreds’.
This is not nearly as much work as in step 11 above, since both of these are essentially duplicates of the
‘Sensor_Units’ sprite that you have just made - and best of all, remember that duplicated sprites contain
the same scripts as their parent sprite!
Go to your ‘Sensor_Units’ sprite in the sprites list and right-click it. You are given the choice of
‘duplicate’ or ‘delete’ so click on ‘duplicate’ and avoid clicking on ‘delete’! You will see a new sprite
(added to the bottom of the sprites list) labelled ‘Sensor_Units2’ - rename this as ’Sensor_Tens’.
Duplicate this once again and label it as ’Sensor_Hundreds’. You might at this stage do as I did and
reposition the order of these digit sprites in the sprites list, sensibly putting them into the standard
mathematical sequence of hundreds, tens and units.
Each of these sprites will have the ten individual costume graphics (1 to 9 and 0) as in the parent sprite
and they will also contain the two scripts that you created for the parent sprite in step 11.
The very good news is that the ’hat’ block ‘when I receive (Change_LED)’ script is identical for all three
of your digit sprites; and since you do want them all to change colour, so there is nothing to change here.
Both of the ‘hat’ block ‘when I receive (Update_Digits)’ scripts in your two duplicated sprite scripts
need to be marginally altered to reposition these new digits to the left of the ‘units’ digit and to choose
the costume matching the tens and hundreds variables.
To do this, go to each of these new scripts in turn and in the two places where each of
these scripts refer to the ‘Digit_Units’ variable replace them with the ‘Digit_Tens’ and
‘Digits_Hundreds’ variables as appropriate for each script.
This all ties in with a principle that you can use in other projects; this good practice concept was hinted
at in step 11 earlier and suggested that using data stored in the variables ‘Digit_Xpos’ & ‘Digit_Ypos’
(and also in the value of the variable ‘Digit_Space’) rather than a value being inserted directly into the
block will allow another script to alter
these variables and thus reposition these
digits as required. This time, the block
modification requires a (minus)
‘Operator‘ block inside the first window
of a (multiply) ‘Operator‘ block.
Since these variables have not yet been set, you might want to
manually position and size these last two sprites. Set the ‘Tens’
sprite to position 125,150 and the ‘Hundreds’ sprite to 100,150.
To enable the ’Sensor_Tens’ and ’Sensor_Hundreds’ digits to automatically position themselves to the
left of the ‘Sensor_Units’ digit you need to set the values of the variables ‘Digit_Xpos’, ‘Digit_Ypos’ &
‘Digit_Space’. This creates a thee digit number that can be easily repositioned - move the units digit,
and they all move! You may also find this concept of considerable value
in other projects.
Go to ‘My Blocks’ in the blocks list and create a new block called
‘Digit_Pos’. Then use three Variables ‘set’ blocks to set the positional
values as shown in the diagram on the right (you might want to
experiment with your own ‘Digits_Space’ value here).
To test that these scripts work, go to the ‘Events’ blocks menu and find the ‘broadcast (message)’ block.
Choose ‘Poll_Sensor’ in the messages list and then click the left-hand end of the block to broadcast the
message. You should now see your three digits react to match the sensor feedback from mBot. You
will also see your analogue pointer fluctuate to (just like it did when you first tested it in step 8).
If this doesn’t seem to work, check the ‘Devices’ tab scripts that you created in step 5 carefully
(particularly the ‘Send_Data’ script that breaks up the ‘Sensor_Value’ into the individual digits that you
are trying to display here).
Step 13: - It’s time to programme the right-hand of the two switches on the interface
that we added in step 4. You could use just about any graphic of your own for this.
I named this graphic ‘Sensor_On/Off’ and it only has one costume, relying on using
the 'change (brightness)' block (demonstrated in step 9) to give an impression of
interaction by dimming it briefly and making a ‘click’ sound whenever it is clicked.
This sprite has only one costume, but it still toggles 'On' & 'Off' in the same way as a two-costume
(moving/changing graphic) sprite would. The ‘when this sprite clicked’ script shown on the next page
essentially sets an 'On' position (1) for a first click and an 'Off' position (0) after a second click of the
same sprite graphic. The ‘Sensor_Pos’ variable enables the ‘Sensor_Lamp’ sprite to toggle between its
two costumes, showing a red lamp for ‘Off’ and a green lamp for ‘On’.
When you try test-clicking the switch sprite on the interface for the first time you should see (if mBot is
connected, that is!) the digital feedback revert to 000 and the analogue pointer drop to 0 when the switch
is ‘Off’ and then real-time sensor data displayed on both when the switch is clicked to ‘On’.
Step 14: - The aforementioned ‘Sensor_Lamp’ sprite needs to be programmed next to complete this part
of the interface involving mBot’s ultrasonic sensor. This is a very simple and speedy modification, as
long as you have the costumes for it ready-made and uploaded into your ‘My Sprites’ library.
The script attached to this sprite (shown here on the right is very
straight-forward and easy to understand. If the switch has a value
of ‘1’ (‘On’) then show the green lamp and if the switch is
anything else, then show the red lamp (‘Off’).
There are initially two scripts that need to be created here and these
are very similar to the scripts created for the right-hand switch sprite
detailed in step 13 previously. These are shown here on the left.
You need to make this second switch script next. This is once again a self-defined ‘My Block’ also
named like its predecessor, ‘Operate_Switch’.
There will eventually be a third ‘My Block’ script ‘Start_Clock’ added to this sprite - but other than
adding the block name as shown in the diagram at the bottom of the previous page, not just yet. This
additional script will be fully completed when the digital clock is eventually created to finalise the
interface.
When this ‘power’ switch is in the 'On' position it allows all the other button sprites to work and
eventually will also activate the 'Start_Clock' display routine. When this switch is in the 'Off' position it
stops the clock and deactivates all of the other button sprites.
Most importantly this script also broadcasts the ‘Move_Monitor’ message which repositions the three
monitor window graphics to the front layer (in front of the three LED displays) to simulate the effect of
the LEDs being turned off.
Step 16: - To enable all of the monitor windows on the interface
to be moved to the front as described above, they each need the
same script attached to them. This script is actioned when the
‘Move_Monitor’ message is received.
It makes sense to also write the usual repositioning script for all three
monitor windows, so return to the ‘Sensor_Monitor’ sprite and create the
script shown on the right. Drag (as you have done before) to duplicate
this on both your ‘Speed_Monitor’ sprite and your ‘Clock_Monitor’ sprite
and adjust the x: and y: coordinates accordingly for each of them.
Create the script shown here on the left and then test-click the
‘Power_On/Off’ button on the interface again - all should work as
before with the addition of the lamp being switched from red to
green and vice-versa. You should be buoyed-up with your
successes once again, so save and backup your project file.
Step 18: - Sliders are a quick way of altering the values stored in a variable and are so useful, that one of
the three monitor windows that can be made visible on the stage to show the contents of a variable is the
horizontal slider shown here on the right. The slider button can be dragged
either left or right to anywhere on its track and the value can be set (in
incremental values of 1) from 0 on the left to 100 on the right.
Sliders such as this are hard to emulate well in an mBlock stage graphic for several reasons.
The first reason being the fact that although sprites on the stage can be dragged, moved and clicked
when you are working in the ‘Edit’ page, they cannot be moved in full-screen ‘Presentation Mode’
where only clicking a sprite is possible. This rules out dragging a slider button up and down (or across)
a slider track.
Secondly, you need a way of analysing exactly where the slider button is on its track and in the example
above, you would need to create 100 rather complex decision making scripts to work out the value
indicated by a slider buttons position.
Thirdly, it’s a complex decision to decide where to position a slider on the stage.
Remember, the zero position for the x and y coordinates of any sprite is in the centre of the stage;
therefore, only sprites in the upper right quadrant of the stage have positive integers and calculating with
negative numbers is difficult.
In the lower left quadrant of the stage, both x and y coordinates are negative integers whilst in the other
two quadrants, one of the coordinates (x or y) will be a negative integer.
For the two vertical sliders that I had in mind for this interface (a LED Colour Changer and a Speed
Changer) I decided that there only needed to be five stopping places for the button on each slider e.g. in
the 0 to 100 scenario described earlier this only need a calculation for every 25 points 0,25,50,75 & 100
and not one calculation for each of 100 stopping points!
Yes, this was the key to solving the problem and if the sprite in question was the slider’s backplate
and not the button then a range of values 0 to 25, 25 to 50, 50 to 75 and 75 to 100 could be used.
If the backplate sprite was clicked somewhere in the 50 to 75 range for example (an actual y pos.
click = 68) then the y position could be told to accurately jump to the next higher value (75) and
the button sprite could move to that position too. Problem basically solved! The button on the
slider needs to be just a graphical adornment - not actually working but just pretending to be the
operating bit of the slider.
In addition to the
‘My Blocks’ self-
defined block script called
Make_Slider_Choice’ shown here
on the left, a second script (shown
at the top of the next page) was
also created to activate the
‘Make_Slider_Choice’ script.
There is a new addition to this script. It uses an ‘Operators’ block to add the value contained in a
variable called ‘Plus_Factor’ to the value of the y pos. variable - but more about this shortly.
The last bit of this script repositions the sprite if necessary and then calls the self-defined block
‘Make_Slider_Choice’ script shown above.
One of these five ‘If’ decisions will have set the new value for the y pos. variable and a specific value for
the slider button position. So finally, the bottom block will be activated to broadcast the message to
move the slider button.
Why is there a sixth ‘If’ decision at the bottom (before the broadcast block)? - This decision looks at the
slider value variable and if it contains 80 it bumps it up to 100 (and is otherwise ignored if the variable
contains any other value). This was a ‘workaround’ I had to invent to correct a problem with the
topmost ‘If’ decision.
When this decision is true, it sets the slider value to 80 (but this really needs to be set to 100 to position
for the button correctly) BUT if 100 was the value returned by this script decision then the slider would
just not work - but why not? I guess that my Scratch programming prowess was just not good enough to
solve this. However, checking the value and changing it again using the sixth ‘If’ decision worked - and
I have no idea why!
Why the need for adding a ‘Plus_Factor’ value of 200 to the y pos. variable? - Setting the ‘Plus_Factor’
to 200 and then adding it to every y position turns all negative integers into positive ones which are
much easier to calculate. (-180 is the lowest y position on the stage) so setting the ‘Plus_Factor’ to 180
would work to create positive values; but a round value of 200 makes the values much easier to
understand.
If you understood all of that, you can now write the ‘when this sprite clicked’ script and the ‘My Blocks’
self-defined block ‘Make_Slider_Choice’ script for your ‘LED_Slider’ sprite.
You can then carry on by making the next very short script too. Creating the ‘when I
receive message’ script for the ‘LED_Slider_Button’ (shown here on the right) is by
comparison very simple indeed.
In this case (because the button has to move when instructed by the
script above) you cannot use the usual sprite repositioning trick that
you have used for all other sprites. All that you have to do is to add
the simple one-block script (shown here on the right) to the
‘LED_Slider_Button’ sprite and this will stop it from being dragged.
When I tested this project on my surface laptop (which has a touch screen) there was a totally
unexpected but massive bonus! I tried operating the sliders with a finger on the screen and not using a
mouse and if you swipe, push or pull the slider button with a finger it really looks as though you are
moving the slider button - but in reality, your finger position when you remove it from the screen is the
last known y pos. and the button glides to that position!
In step 11 you created a script called ‘Change_LED’ and added it to each of the three (hundreds, tens &
units) 7-segment LED digit sprites that you made to provide digital feedback from mBots sensor.
This script uses the value of the ‘Slider1_Switch_pos’ variable that is set by the ‘Make_Slider_Choice’
self-defined block script that you have just created.
A ‘Slider1_Switch_pos’ variable value of 5 sets colour effect of the LEDs to yellow, a value of 4 to Red,
a value of 3 to Purple, a value of 2 to Cyan and a value of 1 returns the colour effect to 0 (reverting each
LED to its original colour, Green).
If you try clicking in the zone below each of the colour names on the slider backplate then the
‘LED_Slider’ button will move to stop at that colour name and the colour of the three LED digits in your
sensor monitor window will change too.
Remember that if you click and drag the ‘LED_Slider_Button’ nothing will happen!
Step 19: -
Now that you have completed
the previous step and have
created one working slider (and
understand the principle of how
it works) you can programme
the second one which will
enable you to adjust mBots
motor speeds easily.
The ‘when this sprite clicked’ script is easy (see above) there are only 4 things to modify. In the two
blue ‘go to x: () y: ()’ blocks, change the value of x in each from -200 to 200 and then change the value
of the orange ‘set (Slider_Xpos)’ block from -200 to 200.
Change the variable name in the orange block below the blue ‘go to (mouse-pointer)’ block where it
says ‘set (Slider1_Ypos)’ and change this to the (Slider2_Ypos) variable name. In the
‘Make_Slider_Choice’ self-defined block script, there are more changes, but these are even easier to
make (this script is shown on the next page).
In the six ‘If’ decisions in this script there are eleven orange ‘reporter’ blocks which report the contents
of the ‘Slider1_Ypos’ variable. Delete all of these and replace them with new orange ‘reporter’ blocks
reporting the contents of the ‘Slider2_Ypos’ variable.
At the very end of the six ‘If’ decisions in this script is a broadcast block calling the ‘Move_Slider1’
message. Change this to call the ‘Move_Slider2’ message instead and the scripts for the ‘Speed_Slider’
backplate sprite are now complete.
It’s time to save and backup your project once again too.
At speed 100 (40%) mBots Real Running Speed = 0.392 x 0.617 x 200 = 48 rpm.
At speed 70 (27.5%) mBots Real Running Speed = 0.275 x 0.617 x 200 = 34 rpm.
At speed 50 (20%) mBots Real Running Speed = 0.1961 x 0.617 x 200 = 24 rpm.
A speed setting of 50 is about 20% power, but to drive mBots motors slowly but adequately 30% power
is rather more realistic; and a speed setting of 100 (which equates to 40%) is a very good speed for mBot
control.
My own mBot veers to the right very slightly: - So to correct this I experimented with adding 2% of
extra power to the right-
hand motor (connected to
motor port M2) - this script
modification worked very
well.
Step 20: - The last block added to the ‘Speed_Slider_Button’ script shown on the previous page is a
broadcast block. The message it is broadcasting is ‘Update_Speed’. This has not been written yet and
needs to be added to three new LED digit sprites which need to be created and displayed in the speed
monitor window below the Speed Settings Slider.
You already have three LED digit sprites named ‘Sensor_Hundreds’, ‘Sensor_Tens’ & ‘Sensor_Units’
which you can duplicate and rename the duplicates as ‘Speed_Hundreds’, ‘Speed_Tens’ &
‘Speed_Units’. You have duplicated sprites before, so go to the sprite pane on the left of the edit page
and right-click on each of your sensor LED sprites in turn and choose ‘duplicate’ from the drop down
list. Name each new sprite as described above.
Each of these new sprites will have the scripts from its parent sprite attached. In each of your new
‘Speed’ sprites you need to keep the ‘when I receive (Change_LED)’ script so that the colour of each of
these new LEDs can still be changed with the colour slider.
Delete any other scripts in each of these new ‘Speed’ sprites in readiness to create the three new ‘when I
receive (Update_Speed)’ scripts mentioned above.
Step 21: - Go to the ‘mBot_Lamp’ sprite and add the short script
shown here on the right. This is another two-way toggle routine of
two sprite costumes and is linked to the position of the 'Start/Stop
Switch' switch.
Step 22: - As I mentioned at the beginning of this chapter, I decided that adding the day, date and time
to my interface might be a nice feature and provide a demonstration of how to add these as graphic
output to any project. The 'workings' of the clock rely on the ability of scratch to extract the sub-
component parts of the current date (day, month, year) and the current time (hour, minute & second)
from the time clock built into all computer
systems.
Once you have completed the first ‘if/then/else’ decision block (extracting the hour part of the current
time) then it is very quick to duplicate it four more times and modify the contents of each to match the
script shown on the left of the previous page. The final block that you need to add (inside the ‘forever’
loop) broadcasts the message to update the clock.
If you want to test that this script works, go to the ‘Variables’ part of the blocks menu and check the
tick-boxes next to the following variables: ‘Cal_Day’, ‘Cal_Month’, ‘Clock_Hours’, ‘Clock_Minutes’
and Clock_Seconds. These variable monitors will now be visible on the stage. Click the ‘hat’ block
'Start_Clock' above where you have just added the decision blocks to extract the sub-components of
your computer systems time clock. The whole script will ‘light up to show that it is running ‘forever’
and you will see that each of the variable monitors on the stage now contains the data showing the day
(date) and month and the current hour minute and second. Click the ‘hat’ block again and the script will
no longer be running. Click the ‘hat’ block once more and you should see the second and possibly
minute variables update themselves. Click repeatedly, and you’ve got yourself a simple clock; and
unless you are doing this at midnight, you will not see the day or year change value!
Step 23: - Once you have the appropriate variables containing the date and time information that you
need; you can get to work on creating digital output to display them in a meaningful way.
To display the time using 7-segment LED digits in the ‘Clock_Monitor’ window that you added to your
interface is a comparatively easy task. To do this you need six separate digits and two spacers (colons)
to display the clock in the format: 00:00:00. Go to your original ‘Sensor_Units’ sprite in the sprites
pane and duplicate it and rename it as ‘Hours_Tens’ - this new sprite should contain all of the costumes
you added (1 to 9 and 0) and it should also have duplicated the three scripts ‘when I receive
(Change_LED)’, ‘when I receive (Update_Digits)’ and the self-defined ‘My Blocks’ ‘Digit_Pos’ script.
Since you have duplicated the existing sprite, it will probably be set to the same size (15% in my case)
but you will need to set the position of this sprite to x: -214 and y: -138 (and you may also need to move
it to the front layer in front of the clock monitor window to enable you to see it). You can now duplicate
your new ‘Hours_Tens’ sprite containing both scripts five more times to make the six sprites required
for the clock. Re-name each of the five newly duplicated sprites as:
‘Hours_Units’ positioned at x: -197 and y: -138,
‘Mins_Tens’ positioned at x: -173 and y: -138,
‘Mins_Units’ positioned at x: -156 and y: -138,
‘Secs_Tens’ positioned at x: -132 and y: -138,
‘Secs_Units’ positioned at x: -115 and y: -138
You should now see all six LED sprites positioned in groups of two inside the
clock monitor window. If not, remember to use this block for each sprite in turn:
If you click a couple of times on the ‘Power_Switch’ on your interface, first on and then off; you should
see ‘working’ clock digits appear and disappear accordingly and if you move the colour slider you
should also see the colour of the LEDs change. The ‘Power_Switch’ does stop the clock script too when
it is in the ‘Off’ position. Finally, you need to create two new sprites (colons) to act as separators (:)
between hours & minutes and minutes & seconds. You should have created a suitable colon graphic at
the same time as you created your numeric digits - the colon should be in the same style too. I made the
punctuation set
shown here on
the right:
To add the two required separators, add a new sprite and add the colon image from your sprites library
(or upload it into the library from your .png files first). Name it ‘Seperator_1’. Set its size to 15% and
its coordinates to x: -185 and y: -138.
Next, you need to create the second separator sprite, so just right-click on ‘Seperator_1’ in the sprites
list and click duplicate. The duplicate will automatically be renamed as ‘Seperator_2’. All that you
have to do here is change the x coordinate in the blue ‘go to ()’ block in the above script to -144.
Step 24: - As you can see from the image above, the weekday and the current date are ‘engraved’ into
my metallic backdrop and just like the clock are programmed to change automatically using the
variables described in step 22 earlier. The ‘engraving’ of the data is such a simple trick, it just requires
the text to be a slightly lighter shade of grey than the background.
First, add a new sprite and choose ‘Paint to open the costume editor and name the sprite ‘Weekday’. Set
its size to 85% and its coordinates to x: -135 and y: -90. There is no ‘reporter’ block like those described
in step 22 to show weekday names as text but there is one (shown here on the
right) which returns the day of the week as a number (1 to 7) with 1 being
“Sunday and 7 being “Saturday”.
You will need to create two scripts for the ‘Weekday’ sprite. The first being
the usual one-block self-repositioning script (shown here on the left).
The second script will be updated by the broadcast ‘Update_Clock’ just like
the digital clock itself so that the correct day will be chosen automatically by a sequence of seven simple
decision processes in the form of “if weekday number is 1 then display costume ‘Sunday’” this script is
shown on the next page.
As this implies, you will also need seven costumes creating for this sprite using text of a suitable size
and colour. Text costumes are a good use of the mBlock5’s costume editor (so no need to use Word!).
Choose ‘Serif’ as the font and click the ‘Fill’ box to set
the following ‘Hue’: 0 ‘Saturation’: 0 and ‘Brightness’:
90. This will make the text a very pale grey. This fill
colour suited my backdrop very well, but you might
want to adjust the ‘Brightness’ value to suit your own
backdrop.
Do make sure that you reposition the text of each costume over the central point of the editor window
using the ‘Select’ tool and also reset the fill colour if you changed the brightness. Close the editor and
create the script shown on the previous page. This is fairly quick to accomplish; all that you have to do
is make one complete ‘If’ decision and duplicate it six times changing the ‘current day of week’ number
and costume name as appropriate. Click the ‘Power_Switch’ on your interface to turn the clock etc. on
and you should now have the day of the week suitably ‘engraved’ on the backdrop of your interface.
Making and programming this sprite is much quicker than this step suggests by its lengthy description!
Step 25: - Adding the date to your interface is very similar in many ways to (and a combination of) the
method of adding the weekday or the clock digits that you have just used. The date will be displayed in
its simplest conventional numeric form i.e. dd / mm / yyyy. As this format would suggest, it needs two
sprites to show the two digits needed to display the day (01 to 31), another two digits to display the
month (01 to 12) and four digits to display the year. It also needs two separator sprites ( / ). This makes
a rather daunting total of ten sprites in all (25% of the total sprites created in this project) but as usual,
these are much quicker to generate than you would think (and note, it is possible to complete this step in
about 30 minutes).
Start by adding a new sprite and then choose ‘Paint’ to open the costume editor and name the sprite
‘Day_1’. Set its size to 80% and its coordinates to x: -166 and y: -105. This sprite needs 10 costumes
making for it (1 to 9 & 0) in exactly the same way as you did in step 24 earlier. Name the first costume
“1” and then type in the costume editor the text “1” (without the enclosing speech marks). Exactly as
you did in step 24, choose ‘Serif’ as the font and set the fill colour to ‘Hue’: 0 ‘Saturation’: 0 and
‘Brightness’: 90. You then need to duplicate this costume nine times more; each costume in turn having
exactly the same single digit for both its name and as the text it will display. The last costume will be
“0”.
You might want to adjust the brightness of the fill for each piece of text temporarily to a darker shade to
check that your text editing of each costume is correct.
It is a fairly simple matter now to duplicate the sprite and name the duplicate ‘Day_2’ and then change
the two blue ‘go to x: () y: ()’ blocks setting the new x coordinate to -159. You also need to modify the
‘switch costume to ()’ block to letter 2 of the ‘Cal_Day’ variable. Click the ‘Power_Switch’ on your
interface to turn the clock etc. on and you should now have the first two days of the current date suitably
‘engraved’ on the backdrop of your interface below the weekday added in step 24.
By now you will have a good idea of how all of this works, so my remaining instructions for completing
the date display can be much briefer!
Right click on the ‘Day_1’ sprite in the sprites list and duplicate it twice. Name these duplicates as
‘Month_1’ and ‘Month_2’ and edit the scripts of each in turn. ‘Month_1’ needs the x coordinates both
set to -147 and the ‘switch costume to ()’ block to letter 1 of the ‘Cal_Month’ variable. ‘Month_2’ needs
the x coordinates both set to -140 and the ‘switch costume to ()’ block to letter 2 of the ‘Cal_Month’
variable.
Click the ‘Power_Switch’ on your interface again and you should now have the two month days of the
current date also ‘engraved’ on the backdrop.
Right click on the ‘Day_1’ sprite in the sprites list again and this time duplicate it four times. Name
these duplicates as ‘Year_1’, ‘Year_2’, ‘Year_3’ and ‘Year_4’ and as before edit the scripts of each of
these in turn. N.B. There is not a variable holding the value of the current year.
’Year_1’ needs the x coordinates both set to -127 and the ‘switch costume to ()’
block to letter 1 of the ‘current (year)’ reporter block.
‘Year_2’ needs the x coordinates both set to -120 and the ‘switch costume to ()’ block to letter 2 of the
‘current (year)’ reporter block.
‘Year_3’ needs the x coordinates both set to -113 and the ‘switch costume to ()’ block to letter 3 of the
‘current (year)’ reporter block.
‘Year_4’ needs the x coordinates both set to -106 and the ‘switch costume to ()’ block to letter 4 of the
‘current (year)’ reporter block.
Click the ‘Power_Switch’ on your interface again and you should now have all of the days of the current
date ‘engraved’ on the backdrop, but they still need the slash separator ( / ) to complete the effect.
Add yet another new sprite and then choose ‘Paint’ to open the costume editor and name the sprite
‘Separator_1’. Set its size to 80% and its coordinates to x: -151 and y: -105. This sprite needs only one
costume made in exactly the same way as the other date sprites. Type in the costume editor the text “/”
(the forward slash symbol). Once again, choose ‘Serif’ as the font and set the fill colour to ‘Hue’: 0
‘Saturation’: 0 and ‘Brightness’: 90. Name the costume as ‘Slash’ and close the costume editor.
In the scripts pane create another of the usual self-repositioning ‘when this sprite clicked’ one-block
script setting the x coordinate to -151 and the y coordinate to -105. No other scripts are required here.
That’s it, your interface is now almost complete - the scripting of its sub-component parts is now
complete so save and backup your project file once again.
Step 26: - This is the final step that you need to complete (and this is a purely cosmetic addition).
The interface looks better if it has three descriptive labels ‘engraved’ into it. You actually need to create
four new sprites for the three labels required. I found that the power switch label did not show on the
backdrop very clearly and there is no way to enhance any text produced using the costume editor; so I
decided to use the old trick of creating a ‘drop-shadow’ effect by positioning a fourth label over the third
one with its x & y coordinates offset by 1. The third label being set to a slightly darker shade of grey.
To complete this effect, you need therefore two duplicate ‘Power_Label’ sprites
Using exactly the same techniques as you employed in steps 24 and 25 create a new sprite and then
choose ‘Paint’ to open the costume editor and name the sprite ‘Title_Label’. Set its size to 55% and its
coordinates to x: 0 and y: 15. This sprite needs only one costume made in exactly the same way as you
have done before. Type in the costume editor the text “mBot Speed & Direction Controller” (without
the enclosing speech marks). Once again, choose ‘Serif’ as the font and set the fill colour to ‘Hue’: 0
‘Saturation’: 0 and ‘Brightness’: 90. Name the costume as ‘Label’ and close the costume editor.
In the scripts pane create another of the usual self-repositioning ‘when this sprite clicked’ one-block
script setting the x coordinate to 0 and the y coordinate to 15. No other scripts are required here. Go into
‘Presentation Mode’ and you should see that you now have a descriptive title positioned in the centre of
the interface between the direction controller sprite and the analogue meter sprite.
Duplicate your ‘Title_Label’ sprite and in the costume editor type in the text “ULTRASONIC SENSOR
- range in MILLIMETERS”. Name the sprite as ‘Mm_Label’ and set its size to 35% and its coordinates
to x: 0 and y: 33. In the scripts pane edit the ‘when this sprite clicked’ script setting the x coordinate to 0
and the y coordinate to 33. Return briefly to your ‘Title_Label’ sprite and in the costume editor use the
select pointer to stretch the text very slightly vertically and then exit the costume editor.
Duplicate your ‘Mm_Label’ sprite and in the costume editor type in the text “SENSOR - range in
CENTIMETERS”. Name the sprite as ‘Cm_Label’ and set its size to 35% and its coordinates to x: 125
and y: 122. In the scripts pane edit the ‘when this sprite clicked’ script also setting the x coordinate to
125 and the y coordinate to 122. Go into ‘Presentation Mode’ and check that you can see the sensor
labels underneath their respective monitor windows - you will also note that stretching the title label has
given it a little more emphasis.
Duplicate your ‘Cm_Label’ sprite and in the costume editor type in the text “POWER ON / OFF”.
Name the costume as ‘Power_Label_1’ and close the costume editor. Set its size to 40% and its
coordinates to x: -120 and y: 60. In the scripts pane edit the ‘when this sprite clicked’ script setting the x
coordinate to -120 and the y coordinate to 60. Duplicate your ‘Power_Label_1’ sprite and name the
sprite as ‘Power_Label_2’ and set its coordinates to x: -119 and y: 61. In the scripts pane edit the ‘when
this sprite clicked’ script setting the x coordinate to -119 and the y coordinate to 61. Return to your
‘Power_Label_1’ sprite and in the costume editor change its ‘Brightness’ setting to 45. Go into
‘Presentation Mode’ and check that you can see the two power labels almost, but not quite, on top of
each other with a slight hint of shadow on the upper side (N.B. This ‘engraving’ method produces a
much more realistic graphic!).
Well done! - Your interface is complete so save and backup your project file for the last time.
If you can make this project, then you can make anything!
Shown below is a screenshot of the complete set of 49 sprites created for my ‘Control Interface’ project.
This is a composite image taken from the sprites list of mBlock 5’s edit page. The sprite icons are in the
order that I left them at the end of constructing my project.
Artificial Intelligence (A.I.) - the science of mimicking human intelligence using computers is arguably
one of the most exciting fields of technological development with far-reaching potential to solve present
day problems. Just as humans store information in their brains and use complex mental processes to
learn from its patterns; computer scientists have been able to use the processing power of computers to
analyze patterns in stored data and allow machines to learn from it very quickly and to remember! This
is called ‘Machine Learning’ which together with A.I. can be used to build ‘Smart Systems’ to
interacting with humans by providing suitable feedback based on complex decision-making algorithms.
Makeblock are, quite rightly, very keen to expose kids to these computer / real-world interactions and
have created several ‘Extension’ packs of programming blocks to enable such work to be undertaken
using mBlock 5. However, as I mentioned earlier when reviewing these (on pages 50 & 51) the
currently available ’Sprites’ tab ‘Extension’ blocks are rather limited in what real-world solutions can
actually be achieved with them! Nevertheless, experimenting with simple Machine Learning and A.I.
feedback using these is still quite good for developing an understanding of some of the basic principles.
Using the ‘Video Sensing’ extension together with the ‘Teachable Machine’ extension makes it possible
to automate Emma’s favourite ‘Rock, Paper, Scissors’ game - a development that uses a web-cam
attached to your computer to sense when a hand movement is made in front of it and then interprets from
learned-shapes what hand you have made; the computer then responds by displaying a random hand
shape of its own. mBot does not need to be involved, so I built this (as demonstrated later in this
chapter) using just ‘Scratch Stage Programming’ but I am still not convinced by the accuracy of the
machine learning ‘recognition’ part.
By combining such feedback with a complex bit of ‘text rendering’ scripting and using the ‘Stamp’
block from the very useful ‘Pen’ extension to display on the stage and concatenating climate data with
linking phrases; and then using the excellent ‘Text-to Speech’ extension to read out those phrases almost
makes (but not quite) the use of ‘Climate Data’ in a ‘Smart System’ worthwhile. I am including
instructions on how to do this not only because this uses three of mBlock 5’s extensions together, but
also because it demonstrates some valuable scripting techniques including the aforementioned ‘text
rendering’ process and a valuable method of ‘auto-starting’ a project when it is loaded.
Climate Data with Digital & Spoken Feedback - a ‘Smart Systems’ development
There are some alphanumeric digits available in the sprites libraries, but they are very cartoon like!
To enable this project to work in the way I was envisaging, I had to create yet more .png sprite images to
act as costumes alongside the set of numeric 7-segment LED digits that I had already created as part of
my preparations for my ‘Control Interface’ project (see Chapter 15).
I needed a complete alphabet of capital letters rather similar to those shown below:
Since I planned on using my italics set of numbers, I needed to create an italicized alphabet too.
Creating all twenty-six letter from my master no.“8” drawing was not as difficult or as tedious as it
might seem since many letters could be created by manipulating the existing segments of my drawing. I
also needed to create some punctuation (. , ; ! ? & ˚) made in a matching style - also not difficult! This
done, I could begin the scripting required. If you have worked your way through my ‘Control Interface’
project, then you are certainly capable of this project with the minimum of guidance.
I used four of my own sprite images for these, but you could use anything else chosen from the sprites
library since none of these sprites are actually displayed on the screen. These four sprites are just a
convenient way of splitting the many scripts required for the project into sensible groups of blocks that
neatly fit into the ‘Scripts Area’.
The 'when (timer) > ( )' hat block provides a cunning way of automatically starting a project if the value
in the hat block window is set to (-1). This setting will immediately run any blocks below it (e.g.
Broadcasts calling specific scripts elsewhere in the project) and any ‘Green Flag’ scripts in the project
will also auto-start.
The scripts required for this project are all called by using ‘Broadcast’ messages.
As you can see above, many of these variables are using the ‘join ( )( to ( )’ block from the ‘Operators’
category of blocks to concatenate external data with meaningful sentence text.
You will also note that I had to make one block to provide phonetic output; which enabled the ‘Text-to
Speech’ extension to interpret “centigrade” and pronounce it correctly by reading “Centy-grayde”!
Mostly, the ‘Text-to Speech’ extension reads text very well, but occasionally you do have to resort to
phonetic spelling to make some words sound right. You can test word pronunciation, if you need, to by
typing variants of any word into the ‘Speak’ block and then clicking it.
I then moved on to my ‘Decisions’ sprite. Here I made the scripts shown on the next page which are all
called by the ‘Make_Decisions’ broadcast. These all use simple ‘If … Then’ blocks - each being
checked as the script runs until one is true and then updating the appropriate variable.
N.B. Scratch only outputs days of the week and months of the year as numbers so conversion is needed
to provide textual output. The main decision to be made here though, is converting the output from the
‘Climate Data’ weather ‘reporter’ block; which returns its textual feedback in ‘sentence case’.
Since I have not created any ‘lower case’ character costumes, my project needs the weather report data
to be converted into capital letters (‘upper case’).
Also, (as far as I am aware) there is no definitive list of possible phrases used to describe weather; so I
have added to this list of decisions using daily ‘trial-and-error’; recording every new phrase generated
as the weather report changed (so my list may still need more additions! ?).
I decided that I also needed a further, slightly more complex decision making script to add the suffix
‘ST’, ‘ ND’, ‘ RD’ or ‘ TH’ to the end of the number representing the day in any month.
This was created rather differently by nesting several ‘If … Then’ blocks using nested ‘Or’ blocks inside
an ‘If … Then … Else’ block.
This script that I created to do this is shown at the top of the next page.
All decisions made; it was time to move on to programme my ‘Display’ sprite. This is where I created
the set of self-defined ‘My Blocks’ shown below:
For this block to work, the ‘Display’ sprite where these ‘My Block’ scripts are being created needs 26
costumes - one for each alphabet letter (from A to Z). Each of these costumes MUST have the same
name as the letter it represents.
The sprite also needs a further 10 costumes, one for each numeric digit and then a 'space' character
(which is just a blank costume!) and its costume name MUST be the equivalent of what you would type
to create a space in text i.e. ' ' but note that you can't see it after you have entered it as a costume name!
If other characters need to be created and used (e.g. the punctuation characters that I mentioned) then
they also must have a costume whose name is the same as the character.
First, I added an ‘Input Text’ box (to insert the text that needs to be processed by the block) - I called
this, predictably, ‘Input_Text’. This is, in fact, creating a new variable name inside the block.
I then added a ‘Label’ into which I typed ‘at x:’ and then an added an ‘Input Number’ box which I called
‘Text_Xpos’ (this is for entering
into the block the x coordinate
of the starting position of the
text to be processed).
This script sets the starting point of the text to be stamped and sets
the stamping position to 1.
I then created the blocks that produce all of the individual lines of text to be rendered using the clever
‘Add_This_Text’ block script shown and described on the previous page:
Switching to the ‘Speak’ sprite it is at last time to make the project talk. Use the ‘Text-to Speech’
extension to create a ‘Speak_Data’ script like the one shown at the top of the next page.
You versus the computer! - a ‘Smart Systems’ development of ‘Rock, Paper, Scissors’
Emma used to enjoy the simple game of ‘Rock, Paper, Scissors’ and as you have seen earlier, we used
the game concept to develop several computerized variants with, or without, mBot’s input. In this
version, which uses a web-cam attached to your computer, the camera senses when a hand movement is
made in front of it and then responds by displaying a randomly chosen hand-shape graphic of its own.
mBot itself does not need to be involved here, but in a continuation of the earlier game projects I have
named “mBot” as the second player (although it is the computer making all of the decisions).
Once again, there is no ‘Green Flag’ script to start this project and once again it
relies on broadcasts to trigger events. You need to begin by creating the five
variables shown here on the left.
Into this sprite I added the three costume graphics used in my last ‘Rock, Paper, Scissors’
project. (see Chapter 12 - page 74). These costumes are shown here on the right. I decided
that the look of this project should remain very simple and retain the ‘drawn on a
whiteboard with a felt-tip pen’ look for these costumes. So, my backdrop is blank - just
plain white – and you can (if you want to) choose your own ‘look’ for this project.
The other three sprites shown above (which I named ‘Player’, ‘Computer’ and ‘Outcome’)
are there just to separate out the scripts that make specific game decisions. They all have
no graphic showing because the first costume in each sprite is a ‘blank’ costume.
It was easy to copy this costume twice more and alter the
‘You made nnn’ text to ‘PAPER’ and ‘SCISSORS’ in each;
and then so simple too to add these to the ‘Computer’ sprite where each occurrence of ‘You made’ was
replaced with ‘mBOT made’ (- this could have been ‘the computer made’ but using ‘mBot’ seemed
best). The same costumes were then copied to the ‘Outcome’ sprite and the text in each changed again
to ‘PLAYER Wins !’ ‘mBOT Wins !’ and ‘It’s a DRAW !’. It is also just as easy to create the single
decision-making script needed for each of these three sprites once and then duplicate & modify it for the
other two sprites.
My ‘drawn on a whiteboard with a felt-tip pen’ project screen layout (with the computer’s random
selection of a hand-movement graphic together with the feedback text from the three text output sprites)
is shown below:
No programming was required for positioning the three text feedback sprites or the hand-movement
graphics - I just went to each sprite in turn and dragged each about on the stage (by trial and error) until
they looked as intended - simple, but effective.
At the top of the next page are the three scripts that select the costume for each of the text feedback
sprites (‘Player’, ‘Computer’ and ‘Outcome’). The ‘Player’ decision is made by the response from the
web-cam; the ‘Computer’ decision is made by random-number generation and the ‘Outcome’ decision is
made by a calculation decision based on the other two.
Make the first script (on the ‘Player’ sprite) and then duplicate it across into the other two sprites.
Change the ‘reporter’ variable that is being compared in each ‘If’ decision as shown in the scripts below,
first modifying the ‘Computer’ script and then the ‘Outcome’ script.
These three sprites scripts are all activated by the ‘Update_Feedback’ broadcast which will then display
the three sets of ‘chosen’ text costumes on the stage.
The principle of what is happening here is right, but I’m still not convinced how good this really is;
nevertheless, it seems to work - sometimes!
The TM category only has one block which accesses a ‘Training Model’ window. This also opens an
integral on-screen ‘Recognition Window’ showing what your web-cam can see.
You need to name three ‘categories’ (rather like variables) which, when the model is in use, will become
available as new blocks added to the extension. These ‘categories’ are ‘trained’ on what the web-cam
can see. Name each category ‘Rock’, ‘Paper’ and ‘Scissors’ and then click the ‘Learn’ button for the
first category and a little thumbnail of the web-cam image will be shown.
Make the hand-shape several times and the ‘Recognition Window’ should start to identify the shape with
the category name. Repeat for each of the categories several times until the ‘Recognition Window’
seems to identify each shape with a good percentage of certainty. Click the ‘Use the Model’ button to
exit training mode.
You now have access to the ‘boolean’ block ‘recognition result is ( )’ which has a drop down list of your
three named categories. You can now add these blocks to the self-defined block ‘Check_Video’ (shown
on the next page) which sets a numeric value for each hand-movement identified by the web-cam.
Finally, to complete the project, you need to create all five of the self-defined block decision-making
scripts; and the short script (to reset the ‘mBOT’ sprites default icon) which are all shown on the next
page.
These are the five self-defined block (decision making) scripts and the reset default icon script.
• Always use a sensible and consistent naming convention for projects, scripts, broadcasts and self-
defined blocks. When you assign names, try to make sure that they are accurately descriptive and
logical. They MUST be understandable to either someone else or indeed yourself when you return to
a programme that you may have scripted months or even years earlier. I always use the underscore
character “_” as a separator to represent a space (making one continuous set of characters) e.g.
using_an_underscore_to_simulate_a_space. This prevents errors if moving your work across into
textual (Python or Arduino) programming.
• Once you have an idea for a project, do carry out some systems design and planning (inc. initial
sketches and logical sequencing algorithms).
• Develop a variety of graphics programming techniques and then always use high-quality graphics to
enable you to create and add to your own bespoke sprites toolkit.
• You MUST develop good housekeeping techniques too. Do aim to keep on top of all your files inc.
their storage to hard disk (always using the grandfather, father, son principle for saving backup
copies). Sensible storage of graphics files, sprites files and the valuable .sprite3 files are vital too.
A very good habit to develop when writing scripts is to use ‘Comments’ call-out boxes frequently to
annotate your projects and make them understandable. It is important to note that descriptive
‘comments’ can be usefully added to the mBlock 5 ‘Scripts Area’ without them being connected by
leader lines to individual blocks.
I do use comments in my projects a lot, but I have omitted them from most of the script sequences
demonstrated here since they are fully described in each project sequence.
If you add a ‘comment’ to an individual block, then the leader lines are attached to the right-hand end of
most blocks (but from the middle of a ‘My Blocks’ hat block). If blocks are nested inside other blocks,
then the leader line is attached to the right-hand end of the nested block which was right-clicked to add
the comment.
‘Comments’ call-outs now look much neater, sharper and clearer than they ever were in mBlock 3. The
leader-lines now remain connected to the block that the comment refers to too and they can now be
positioned anywhere with the leader lines at any desired angle (not just horizontal like before!) - much
improved, but not yet perfect! Sadly, they still tend to move and reposition themselves, particularly if
you open and then close the code comparison windows which pull in or out from to the right edge of the
interface.
mBlock 5 filenames in your ‘My Projects’ window (in the Makeblock Cloud) show a maximum of
fifteen characters (but only fourteen when you are editing them). When developing a project, I always
save my files with short filenames (10 chars. max.) appending v. 1, v.2 etc. to each modification of a
project. In this way the whole filename can be seen under its thumbnail including which version it is.
I have found this useful - even though the file thumbnail also shows the info. (minutes days or weeks
since last saved).
‘My Projects’ is just one large storage area and any files stored there will are always visible with no way
to logically subdivide or order them. You have to sign-up or sign-in to mBlock to use their cloud
service. To do this, you click the sign up / sign in icon at right-hand end of the tool bar.
If you double-click (or right click) on a mBlock 5 filename in the cloud and choose to edit the name,
then it becomes highlighted, showing that it has been selected. Unlike other forms of text editing you
cannot click again to position an ‘insert point’ to edit just part of the filename. This is a little tedious,
but there is a way round this. Just press one of the cursor keys on your keyboard. This will deselect the
highlighting of the filename slot but remain in editing mode and you can now move the ‘insert point’ to
anywhere in the filename to edit it. ‘Up’ moves the cursor to the start of the filename, ‘Down’ moves it
to the end of the filename; whilst ‘Left’ and ‘Right’ move the insert point one character in the indicated
direction.
N.B. Long text strings in ‘input slots’ / ‘bubbles’ in mBlock 5 programming blocks obey the same
editing rules described above.
mBlock 5 does not use the standard Windows format (three-letter, occasionally four letter) extension for
files - it uses six letters for its Windows PC file extension (.mblock) and it only recognises this as well as
the older .sb2 and .sb3 file extensions and the .json - JSON file format (JavaScript Object Notation)
which is a standard data interchange format primarily used for transmitting data between a web
application and a server.
Do be aware that if you try to open an old .sb2 file (created in mBlock 3) in mBlock 5 then the file may
open, but without any of the robotics blocks originally in that file showing in the ‘Scripts’ area.
mBlock 5 now (since the July v5.1.0 update) also recognises the very useful (but unusual) .sprite3
extension. This is used to save sprites, and rather more importantly their attached block scripts,
costumes and comments.
If you have installed the mBlock 5 application to its default location on a PC, then it’s hard to locate the
mBlock 5.exe file if you want to choose the App required to open mBlock 5 files using the ‘always open
with this file type’ dialogue.
It is well hidden, but I looked at the desktop shortcut icon’s properties to see the path to the .exe file and
found it hidden in an ‘invisible’ folder on the C drive of my PC. The full default path to the .exe file is
as follows:
C:\ProgramData\mBlock5\mblock\mBlock.exe
To see it, you need to choose ‘View’ from the menu at the top of the primary C drive folder and then
check the box, ‘Hidden items’. You could perhaps install the software to a more accessible and visible
folder instead?
If you use mBlock 5’s ‘Save to your computer’ option, files will be automatically added to the last folder
you used in your own filing system - unless you reset the file path to your folder of choice. Project files
are otherwise saved to 'My Projects' in the mBlock cloud for quick access.
The Makeblock Cloud is nearly always fast and reliable, but it does ‘hang-up’ & stop sometimes. I
would always recommend using the ‘Save to your computer’ option as a secondary storage method and
I do use the ‘My Projects’ cloud storage option with my own mBlock 5 files - BUT - I always make a
disk backup frequently too. It makes sense to only use ‘My Projects’ for work in progress; and then
emptying out by archiving your files to storage in folders on your hard-disk when completed. As long as
you sign in to mBlock 5, either on your PC, using a web browser, or the mBlock mobile app. you can
always find your ongoing projects in your ‘My Projects’ page in the Makeblock cloud from anywhere!
If you, like I did, started your programming journey using mBlock 3 then any files you created there are
redundant and need to be totally reworked in mBlock 5 should you still need to use them. There is no
conversion process available and it seems that old .sb2 files can only be opened in mBlock 5 by
changing the extension to .mblock - but it’s hardly worth the trouble since they often fail completely or
do not transfer correctly. The main problem with moving files across from one system to the other
seems to be with the fact that mBlock 5 now has two separate programming areas (the ‘Devices’ tab and
the ‘Sprites’ tab) whereas mBlock 3 just had one programming area for both robotics block
programming and sprite programming.
Early on in my experiments with the new application I found that it was not worth trying to open any of
my old files this way in mBlock 5 but I did find however, that I could open mBlock 3 and copy text from
any comments boxes to a temporary text file and then paste the text into new comment boxes attached to
blocks in mBlock 5 - this saved time, but was only worth it if they contained a lot of detail!
So on-the-whole, totally rewriting scripts in mBlock 5 is actually quite quick, especially if you capture a
screenshot (in mBlock 3) of any block scripts that you want to recreate and then rebuilding them in
mBlock 5 using the screenshot (or a print-out) as a guide.
A useful way of starting mBlock 5 is to make mBot your ‘Regularly Used Device’, making it the default
device (not ‘Codey’) set to appear each time you open a ‘New’ project. Open the ‘Device Library’ list
and hover the cursor over the top left corner of the mBot device icon. A hollow blue star will become
apparent, click the star to make it turn solid blue - this will make mBot the default start-up device.
It is even quicker to get going with mBlock 5 by setting up the way you like to use it and then saving
this set-up as a file on your computer for re-use, adding a shortcut to this file on your desktop. Every
time that I use the Block 5 application, I now choose a shortcut icon on my desktop to open a file saved
as ‘mBot Setup Page’.
I also have a copy of this file saved in ‘My Projects’ in the cloud.
To create this file, (if you haven’t yet used the ‘Regularly Used Device’ adjustment described above),
open mBlock 5 and from the ‘Devices’ tab, open the device library and add the mBot sprite as a new
device. Then deleted the ‘Codey Rocket’ sprite as an available device leaving mBot as the only icon in
the 'Device' sub-panel. Switch to the ‘Sprites’ tab and delete the default ‘Panda’ sprite, replacing it with
a sprite of your own choosing. I used one of my own mBot drawings - not crucial, but it looks good.
Change the name of this new ‘Sprite’ to ‘Set-Up’ both in the editor and in the ‘Sprites’ tab and finally
add a suitable background image to give the stage some meaning - always better than it remaining white!
I used my ‘Graph Paper’ backdrop. It’s also a good idea to add the useful ‘Makers Platform’ extension.
Save the file (I called mine ‘mBot Setup Page’) and make a desktop shortcut. See Chapter 5 (page 21)
and Chapter 9 (page 42) for more on my setup page.
It may seem presumptuous for me to suggest this but having a sensibly organised file hierarchy is a very
good habit to adopt. When I started my mBot programming journey I set up an ‘mBot Stuff’ folder in
my own user documents in my PC’s filing system. I added the folders shown below to organise my
files:
My Project Scripts Scripts Sprite Files Backdrop Files Graphics Files Sound Files
Files (Sprite3) Files (Grabbed Screens)
Misc. Tests Movement Simple LED Panel Stage Display Extensions Advanced
Tests Games Tests Tests Tests Projects
These files are VERY useful because they are a way of storing and retrieving scripts
for future use but by default they have the plain ‘unknown file type’ icon (shown on the
right). Since these are not immediately linked to mBlock5 I had to right-click one of
them and choose the app that would always open the .sprite3 file extension. It’s not
crucial to do this since you import these files into mBlock 5 when needed, but I did it
anyway and the plain icon for all of these was replaced by mBlock’s ‘Panda Cog’ icon.
The sub-folders within my ‘Project Files’ folder are also shown as part of the filing system diagram on
the previous page - some of these folders have sub-folders too.
My ‘Sprite Files’ folder is quite important as it stores (in several sensibly named sub-folders) the sprites
making up my oh-so-useful’ sprites toolkit.
My ‘Sound Files’ folder stores a few sounds - but not many are needed for robotics. Sound files do
have their uses but do remember that they play through your computer’s speakers and not through mBot.
If you click on the ‘Sounds’ tab in mBlock 5 you will see that there is just one default sound file, 'Pop'.
I deleted this from my ‘mBot Setup Page file too before saving it. It is easy to add more sound files as,
when and if, you really need them in a project.
Raising the back of the robot up off a desk or table-top is easy to do if you put something about 20mm
high under the area (where the back axle would be if only it had one!). This use of an ‘axle-stand’ is
highly desirable and avoids mBot thrashing about if it does go amok and for some reason you
unintentionally start-up its drive motors.
It’s not too difficult however to make a special worktop tray, a ‘service bay' (or ‘sick-bay’ perhaps) to
mount the robot with its wheels raised. A board with a small block of wood screwed on to it can provide
a permanent ‘axle-stand’ and if the front of the robot is temporarily attached to the board by a couple of
bolts put through the big (8mm dia.) holes it will hold and steady mBot; which is ideal when modifying
& testing new components.
The grooves around the board retain screws very usefully when assembling extra components.
Additional Storage
This was a creation of Javier & Eva Venegas who have a Spanish educational website: 'KidsandChips' -
a site showing (for a variety of platforms and kits) educational robotics projects which are capable of
being constructed and programmed by anyone. The site is written in Spanish, but it is translatable by
Google (to see it, use the following link):
www.kidsandchips.es
As much as I liked the ‘KidsandChips’ radar simulator project, I really did not like the method they used
to rotate mBot. This required the removal of the wheels and motors from mBot’s chassis and then one
motor and wheel fixed below mBot at the natural balance point. OK, it seems to work - but so
vulnerable to damage since the whole model is balanced on the single (not over strong) integral axle of
one motor. Makeblock do include spare motor shafts in the mBot kit - probably for good reason! Below
are two views of this cut from the ‘KidsandChips’ YouTube video - to my mind, a rather scary balancing
act:
My first though on modifying this project was to keep mBot more-or-less intact. In Appendix 13 (page
243) which outlines ‘The Intelligent Desk Light’ project I indicated my reluctance to dismantling mBot
by substituting mBots chassis for an aluminium ready-meal tray to make a lamp-shade.
Could I not make mBot rotate on the spot by driving one wheel forwards and the other wheel
backwards? A brief test of this showed that mBot could indeed rotate, but it moved about a bit and did
not remain on the spot.
I also found the motors supplied with mBot needed a speed setting of 30% to drive mBot happily; this
gave mBot a rotation time of about 6 seconds per full revolution. What I needed I thought was a
baseboard with an upright pivot spigot through it and a pivot hole on the underside of mBot in line with
the two axles and midway across the chassis.
You can just see from the pictures above that the
‘KidsandChips’ team used cuttable linkages bolted to
the underside of mBots chassis to mount their motor.
You can also see that that I had to remove the line-
following sensor and the front wheel to utilise the
threaded holes on the chassis - as a bonus however
this allowed me to reposition the front wheel at 90º
to its normal position allowing it to follow a circular
track around the pivot easily and with minimal drag.
I positioned mBot with its new pivot point fitted over the
central pivot screw on the baseplate disk and was ready for a
second test. It worked as expected - a perfectly smooth
rotation and the front roller-ball wheel equally smoothly - a very successful experiment!
Another mBot based project on the 'KidsandChips' website also attracted my interest. This was another
YouTube video of a simple mBot powered ‘Spirograph’ drawing machine; it was so intriguing that it
inspired me to start an mBot ‘drawing machines’ project. You can this inspiration for yourself at:
https://www.youtube.com/watch?v=-Biq2Hys-5w
One particular project on yet another Spanish website shows in quite some depth, robotic sensing and
logical decision making in getting mBot to escape from a labyrinth. The line-follower sensor and
ultrasonic sensor that come with mBot are the only sensors needed to implement an outstandingly good
and well documented maze-solving algorithm. This website contains much valuable information and it
is authored by Dani Sanz, a professional who specialises in on-line courses in educational robotics. I
may well try out his ideas too - the link to his work is:
https://juegosrobotica.es/
Eventually, I got back to recreating this project using mBlock 5. This was a little harder to achieve since
I had to juggle robotics scripting on the ‘Devices’ tab and stage graphics programming on the ‘Sprites’
tab. I had to wait another four months before I had developed my understanding of mBlock 5 enough to
be able to rewrite this.
At its simplest, this project needs mBot to rotate on its own axis (with the ultrasonic sensor mounted
vertically above that axis - as shown on the previous page) and the x and y coordinates of the position of
any identified objects around mBot then calculated from two pieces of data.
The first needs the sensor to be repeatedly polled and the data feedback transmitted to Mblock 5 whilst
the second needs to be estimated by timing (matching as closely as possible mBot’s rotation speed).
Using these two pieces of data and some simple trigonometry, the x, y coordinate positions of any
objects identified around mBot can be identified by processing the following two formulae:
Using mBlock 5’s potential to link and interact with feedback from mBot’s sensors via ‘stage’ graphics
enables you to create the illusion of a ‘Radar Screen Display’. The project backdrop that I created is
shown above. This has on top of it a rotating analogue ‘Sweep’ graphic, which moves in sync. (more-
or-less) with mBot’s on-the-spot rotations and using the basic mathematical principles outlined on the
previous page, the identified position of any object around mBot can be used to position a pen-drawn
‘Radar Contact’ graphic on top of the radar display.
The sweep indicates the bearing direction being polled and the ‘Target Bearing’ window shows this
numerically too. The ‘Target Range’ window shows the current reading from mBot’s Ultrasonic Sensor.
N.B. These two windows use the graphical LED digits used in my ‘Control Interface’ project (see
Chapter 19).
I began this project (initially using mBlock 3) by testing the ultrasonic sensor. I pointed mBot at a wall
and using a tape-measure to position it noted the sensor feedback readings at different distances. Rather
disconcertingly all readings were 27 - 28% less than the distance indicated by mBot’s position on the
tape-measure. I also noted that the sensor values constantly fluctuate slightly if the sensor is detecting
something, but the sensor always returns 400 if it is not detecting anything (its out-of-range reading!).
On the next page is the algorithm that I devised to work out the sequence of how the project might work:
Start
•
My Basic Concept Algorithm
for an mBot
‘Radar’ Screen Project
Power
No Yes
Switch ON
Power Lamp
turns Green Poll mBot
Sensor
Rotate
mBot Calculate Calculate
Bearing Range
(plot angle) (plot radius)
Display Display
Bearing Range
Calculate
Contact (x, y)
Position
No Range <400
Yes
Warning Warning
Lamp turns Lamp turns
Yellow Red
Display Display
Normal Close
Contact Contact
As outlined earlier, the problems with using the ultrasonic sensor are twofold. Firstly, my ultrasonic
sensor under-reads by about 27% (this may vary slightly for individual Me sensor modules?).
Secondly, the point at which the sensor stops reading distances (its range) varies according to the
ambient light around it and the range of the sensor is nowhere near the 400cm (4M) range expected. I
guess that each individual Me sensor might vary slightly in this too.
• In bright daylight (outside) my sensor monitor reading did not start to fluctuate from a
fixed 400 until it was below 150cm (1.5M) - an extremely poor result!
• Indoors (in reasonable daylight) the sensor monitor started to fluctuate at 230cm (2.3M)
and with curtains drawn (performing in subdued light) it still only started to perform at
270cm (2.7M)
• Testing it at night, in darkness, the sensor monitor readings begin to fluctuate at 330cm
(3.3M) - which corrected by adding 27% gave a max. range of 4,2M.
Matching the on-screen radar sweep graphic’s speed with mBot’s rotational speed is hard to achieve
with any degree of accuracy, so as usual, I carried out several ‘test-bed’ exercises first with both the
graphic rotation and the speed of mBot.
I discussed motors in Chapter 15 (on page 125). Individual motors will vary in output to but generally
are only reliable at speed settings of over 30% (76.5/255). At speeds lower than this, mBot's motors
tend to stall. This speed (the slowest I can reliably set) will rotate mBot clockwise in approx. 6 secs per
revolution. Carrying out programming tests relating to rotating the radar sweep, I settled on making it
move in 10˚ increments which still looked fairly smooth in action. I also found that to match mBot’s
rotation speed I had to build in to the rotation script a delay (wait) time of 0.13 secs per 10˚ of revolution
of the graphic for it to match mBot.
N.B. 0.13 x 36 = 4.7 secs; but even though (0.165 x 36 = the required 6 secs ) a wait time of 0.13 secs
worked best in my tests. You might (& probably should) test both your own motor speeds and measured
readings from your own ultrasonic sensor.
Experimenting with a ‘Sonar Ping’ sound file was valuable too. Adding one which lasted just under 2
seconds added much to the illusion but needed playing ‘until done’ rather than just ‘started’, which
cropped the sound into a short blip.
Once I had established the basic principles of what I wanted to achieve it was time to begin
programming the project in mBlock 5. On the ‘Sprites Tab’ I created the following eleven sprites:
The two ‘Lamp’ sprites are named ‘Lamp_On-Off’ and ‘Lamp_Warning’. The three ‘Bearing’ and three
‘Range’ sprites are appended with ‘_Hundreds’, ‘_Tens’ and ‘_Units’ in exactly the same way as they
were in my Control Interface project (see Chapter 15). I had saved one set of my LED sprites from that
project as a .sprite3 file and I was now able to imported it into this project and duplicate it; which saved
much time and effort!
The two ‘Lamp’ sprites need the same four costumes added to
each of them (so just make one sprite & then duplicate it!).
The ‘Contact’ sprite contains NO graphic costumes as such, but to exist, it must have a blank costume
that cannot be seen on the stage. This sprite is just a neat way of containing all of the scripts require to
position, draw and ping any identified ‘radar’ contacts.
The LED sprites had all of their costumes imported with them when I
loaded my .sprite 3 file. The first sprite that was imported, was duplicated
five more times to create the six LED sprites required for this project.
From now on, I intend to provide the bare minimum of explanation, but I hope that I will have provided
you with enough clues on the following pages to enable you to create this project.
After setting up the sprites required, I created the following Broadcast message names:
On the next page is a screenshot of all of the ‘DEVICES’ tab scripts. These are required to operate mBot
and to provide feedback back to the ‘stage’. Only one script is required to start mBot’s motors. Adding
+2 to the motor power on port M2 corrects a slight difference in speed between the motor on port M2
and the marginally faster motor on port M1 - you may need to make a similar adjustment. N.B. Using
'anticlockwise' for each motor turns mBot to the right - clockwise!
On the next page are the ‘Switch’ sprite scripts created on the ‘Sprites’ tab. The ‘switch’ (activated by
the ‘when this sprite clicked’ hat block) sets up all required variable values and starts both mBot and the
‘Radar Screen’ graphic.
N.B. Full-screen ‘Presentation mode’ needs to be selected but there is no way of automating this feature.
(1) Setting
‘mBot_Speed’ to 30%
will make mBot’s
motors work at a
speed of 76.5 / 255.
At speeds lower than
this, mBot's motors
tend to stall!
(2) Setting a
‘Sweep_Speed’
timing interval of
0.13 will give a 6
second rotation time
for the sweep graphic
(which matches the
time it takes mBot to
complete one
revolution).
(3) Setting the ‘Sensor_Adjustment’ to 27/100 (27%) gives a sensor feedback value equivalent to the
actual distance targeted.
Shown below are the three short ‘Lamp_On-Off’ sprite scripts, which are activated by the movement of
the ‘switch’ sprite broadcasting the ‘Switch _Lamp’ message.
On the next page are all of the ‘Contact’ sprite scripts. You can probably see why they required a sprite
to themselves even though a sprite graphic is not needed, only the transparent (invisible) one mentioned
earlier. I tried experimented with using sprite costumes and stamping them on the stage display for this
project but using the pen to create the contact graphics provided a much neater solution.
A critical addition to the main ‘Check for Contact’ script is checking if the ‘Sensor_Value’ is not in
range (showing 400) and then exiting the script if true. The ‘‘Set_Target_Pos’ block script does the
maths described at the beginning of this chapter to convert the sensor feedback into a contact position.
N.B. The centre of my ‘radar’ display screen is positioned at x 0, y -8, so adding -8 to ‘Ypos’ (in
‘Set_Target_Pos’) allows for this; and since the display has a diameter of 240 pixels then the script also
sets the ‘Max. Plot_Radius’ to 120.
The ‘Adjust_Position’ self-defined block script offsets the start position for the drawn triangle, enabling
it to be positioned evenly over the target position whilst the ‘Ping_Contact’ block script contains the
method I eventually devised to play the two second ‘Sonar’ sound successfully.
Next, are the sets of scripts for the three individual sprites required to display the three digits
of the ‘Bearing’ (angle of the ‘Sweep’) using the LED digits from my graphics library.
Below is the single script required for the ‘Bearing_Tens‘ sprite and slightly below that, the single script
required for the ‘Bearing_Hundreds‘ sprite.
‘Range_Units’ sprite
‘Range_Tens’ sprite
‘Range_Hundreds’ sprite
N.B. A ‘Spirograph’ actually uses meshed gear wheels to generate the graphics, which this model does
not. I decided that I would attempt to make several mBot variants of the most commonly found
drawing machine types that use a ‘crank-arm’ to convert rotary motion into linear motion. These will
require hardly any mBlock scripting (other than that needed to start and stop the motors). However, they
will need virtually all of a working mBot to be dismantled to redeploy the parts required. These models
will also need many of the additional Makeblock components I have acquired (from add-on packs) too.
The 'Pantograph' (its earliest form was for copying writing and dates back to the early 1600’s) is a
mechanical linkage based on parallelograms so that the movement of one point or pen, in tracing an
image, produces identical movements in a second point or pen. If a line drawing is traced by the first
point, an identical, enlarged, or miniaturized copy will be drawn by a pen or other device fixed to the
second point for duplication, sculpture, minting, engraving or milling. In 1827 an English architect and
engineer, Peter Desvignes developed a machine to create elaborate spiral drawings intended to prevent
bank note forgeries. He called this a ‘Speiragraph’.
In 1965 Denys Fisher first exhibited his very successful variation on this theme, a toy which he called
‘Spirograph’. This has now become the ubiquitous generic term for the generation of graphics using
mathematical ‘roulette’ curves technically known as hypotrochoids and epitrochoids.
This ‘programming only’ solution however does not make use of your mBot at all and my aim was to
create mechanical drawing machines which could draw with a real pen on real paper.
I experimented with several variants of these machines, the first one very much simpler than the
‘KidsandChips’ version which had inspired me to start this project. Both of these use a moving arm or
arms operated by a crank to manipulate the pen and they also rotate the paper which generates petal-like
lobes. These types are generally known as ‘roulette’ drawings and are bounded by a circle, just like a
‘Spirograph’. As hinted-at on the previous page, your mBot needs dismantling to provide you with the
required components.
This did not take long. I removed the drive wheels, the motors, the line-follower module and the front
mini-caster wheel, leaving the ultrasonic sensor module in place and the mCore board inside its
protective casing (its cover) still secured to the chassis by, and supported on, four hexagonal 25mm brass
spacer pillars.
Despite my reluctance to destroy a working mBot robot; it is actually very rewarding to have all of its
components available (together with any other parts accrued from add-on component packs) to enable
you to experiment with mechanisms.
I had in mind what I wanted to try first and it took me about five hours of happy fiddling to come up
with a working solution. It’s creation was quite literally a ‘top-down’ approach to model-making by
first working out how paper could be attached to one of the motors (using one drive wheel) whilst the
other motor and second drive wheel provided a crank-drive to a move a pivoting arm. The tyres were
then removed from the wheels. Without the tyres, the drive wheel are 58mm in diameter.
How to hold-down and support the paper on top of one of the drive wheels? I needed to fix something
to the gear wheel - carboard, too bendy; plywood OK but heavy; so probably some form of plastic then?
All of the images generated by this device would be circular. So circular in shape, what could I use?
I had a bright idea and sat an old Compact Disk (CD) on top of the drive wheel. It looked to be (at
120mm dia.) slightly too small, but it seemed a very neat and lightweight solution. I found an old
erasable/recordable CD I had used years earlier to store computer data and peeled off the sticky label
that I had added to it. This produced an unexpected bonus in that most of the shiny reflective recording
surface came off with it. After a few rubs with an abrasive washing-up pad the remainder came off too
leaving me with a very neat clear (with a blueish tinge) plastic disk, marginally scuffed by the scrubbing,
but perfect for the job.
I carefully measured across one of mBot’s drive wheels and the outer
ring of four holes seemed to be spaced at 48mm dia. centres. I used a
pair of odd-leg callipers to mark a circle 48mm dia. on to the CD. I
put the gear wheel on top to check that I could see the circle through
all four holes and clamped the wheel down on to the CD to use it as a
drilling jig to drill four 4mm holes through it.
The pan-heads of these were slightly raised (about 2mm) above the surface of the CD - and the CD (as
they do) had a hole in the middle, so I now needed to create a flat surface above the screw heads. I
decided on making a covering disk of two layers of 2mm thick cardboard (this was just about cuttable
into 120mm circles with sharp scissors).
I bolted the CD on to the drive wheel and intended to use ‘Glu Dots’
(thin sticky pads) to attach the two-layer cardboard sandwich to the
CD, but I couldn’t yet - not until after the drive wheel has been
attached to the spindle of the motor using its central self-tapping
screw.
I was pleased with this CD and cardboard sandwich assembly which didn’t seem to add much to the
overall weight of the drive wheel once it was attached to the paper-drive motor. My plan for adding
drawing paper to the machine was to attach individual disks of paper to the flat cardboard top surface
using ‘Glue-Dots’ as required (and it is very easy to draw around another old CD, fitting three 120mm
circles on to one A4 sheet of paper and then cutting them to shape).
The second problem was how and where to mount the motors bearing in mind that the cable from each
motor is only approx. 160mm long; and to obtain power they need to reach to the M1 & M2 motor
connection sockets in the middle of the left side of the mCore circuit board. This means mounting the
motors to the rear of mBot’s chassis and at about the same height as the mCore board; unless the mCore
board is detached from its usual position on top of the chassis.
N.B. It is quite hard to extract the tight-fitting plugs on the motor cables from their sockets so it’s quite
important to use a small pair of ‘snipe-nose’ pliers to hold them firmly whilst removing or locating them
into the tiny sockets on the mCore board.
The two drive motors have just two mounting holes, 2,5mm dia. at 17mm centres apart and use two
M2.5mm x 25mm screws to attach them to either side of mBot’s chassis. Trying to attach them to
standard Makeblock components (plates, beams & linkages) is not straightforward since these all have
4mm dia. holes at 16mm centres! I was tempted to try increasing the holes through the motor casings
very slightly but didn’t dare to in case the motors were damaged; but with a bit of fiddling, the two
screws will just pass through every other hole in a beam or linkage. Not, good, but it works!
Holding the pen firmly in these drawing machines is also a problem. The ‘KidsandChips’ model and
many others on the internet are rather wobbly, just relying on rubber bands to hold a pen against an
upright.
With this very simple ‘roulette’ drawing machine, there are only two
ways to enable variations in the pattern generated. First, try varying the
paper speed (which widens or narrows the drawn ‘petals’) and then alter
the position of the crank-pin (which will give the arm a longer or shorter
stroke, lengthening or shortening the drawn ‘petals’).
Emma had a good idea. She suggested that we added one of her multi-
colour pens into the holder where we only then need to click a button to
change the pen colour - but finding one narrow enough to fit the holder
was not easy. We did try it with some success using a 4-colour pen. I
preferred the black pen, but she really did like her multicoloured option!
Despite being rather limited in what it can do, it is still worth making this
model before the slightly more complex build of the ‘KidsandChips’
version which was my original inspiration.
You should be able to see clearly how this model is assembled and how it
works from the picture below:
To emulate the ‘KidsandChips’ version (which, with its second arm, can produce more pattern varieties)
required a rather more complex build. I started by removing the four screws that held mBot’s plastic
cover in place over the mCore circuit board and then re-secured the cover by adding a second set of four
25mm brass spacer pillars with their screw ends passing through the cover and into the threaded holes in
the brass pillars below. I used the largest hexagonal hole in the body of the little spanner to tighten these
- firmly, but not too tightly since they were compressing the plastic casing.
I then used two M4 x 8 screws to attach the end hole of a complete (160mm) length of 20-hole cuttable
Linkage to two brass pillars at the rear of mBot. Do not add any screws - yet into the front two pillars.
This will be done when you add the motor beam shortly. To the outer ends of each piece of linkage, I
added a 3-hole x 3-hole right-angle bracket using just one 8mm x 4mm Screw and Nut as shown above.
To give this construction some rigidity, you can also see clearly in this image that I added a 9-hole,
76mm 0412 beam to act as a bracing strut using two 8mm x 4mm Screws and Nuts (the bottom one
passing through the topmost hole of those that form a circular pattern at the front of mBot). I did the
same on the opposite side of mBot too. You will also notice that I added a further 3-hole x 3-hole right-
angle bracket to the just the left-hand side of mBot to provide a little extra width to the chassis base,
making a supporting ‘foot’ (fitting flush with mBots chassis base).
I used two 8mm x 4mm Screws and Nuts passing through the ‘M’ shape cut into mBots left side to
secure this in place. I did not need to do this on the opposite side since, as you will see on the next page,
the left side of the motor beam assembly overhangs a little more than it does on the right and the one
remaining right-angle bracket at my disposal was required elsewhere in the model.
The motor beam is constructed from three 9-hole x 2 (Code I1) Slotted Plates with the motor for the
paper rotation wheel mounted below it (to get it the wheel as low as possible) and the motor for the drive
crank mounted above it to get the wheel as high as possible so that the crank linkages (and pen carrier)
would pass easily above the rotating paper.
The motor for the drive crank is mounted at right angles across the second I1 plate using the second and
fourth holes on the back-edge of the plate; and once again, using the same two bolts that were used to
secure it to mBots chassis.
You can also see in this image that to complete the support system needed for the pen carrier and crank
linkage pivots, I added two more 25mm hexagonal brass pillars to the front ends of the longitudinal cut
linkages securing them underneath the angle brackets with two M4 nuts and on top of these pillars I
added a 10-hole, 90mm 0412 beam.
Next, I fitted the two drive wheels back on to the axles on each of the motors, securing them with the
small self-tapping screws carefully saved when mBot was disassembled earlier. I then connected each
of the motors to the mCore board using socket M1 for the paper rotation motor and socket M2 for the
linkage crank motor.
I used my paper support plate (CD /
cardboard assembly) from the last
model and used the same pen holder
from that model too. You should be
able to work out from the picture on
the left and the one shown at the top
of the next page how the arm linkages
work.
All of the 25mm brass pillars have an M4 threaded hole in the top & these holes are 9mm deep. Use a
14mm M4 screw in the top of the secondary pivot and a 22mm M4 screw in the top of the primary pivot;
these should stop firmly at the bottom of the hole (providing a bit of friction to prevent them from
unscrewing) and leaving just enough movement for both of the linkages to turn freely. Use an M4
Nylock nut on the underside of the secondary pivot to fix it firmly to the crank linkage; since this needs
to be repositioned to create different patterns, I used an M4 wing nut to do this.
For the crank fitted to the outer ring of holes in the crank-wheel, I attached the linkage using an M4 x
22mm screw with a 2mm spacer on both sides of the linkage and an M4 Nylock nut on the top. Check
the screws on top of the two pivot pillars are tight - the primary pivot of the pen arm, especially, can
work loose.
All drawn output from this model will still produce variants on the ‘petal’ theme. As before, increasing
the paper motor speed creates a wider spacing of the lines whilst decreasing it produces a finer spacing.
Repositioning the pen arm on the top of the primary pivot moves the pen out further from the central
axis giving a larger diameter central ‘hole’ where the created patterns create a circle at the centre of the
‘petal’.
Finally I tried a totally different type of drawing machine to the two rotating paper ‘roulette’ types
outlined above. This turned out to be very much simpler to build, to experiment with and so much
more satisfying to watch in use. In this model variant, the paper remains fixed whilst mBot’s two
motors drive a linkage system via two rotating cranks to push-and-pull a pen across the paper.
This type of model is generally referred to as a ‘Pintograph’ and there are many examples of these to be
found on the internet. I found a particularly useful website created by American, Wayne Schmidt where
one of his pages explains the practicalities of pintograph construction and use in some considerable
depth. This can be found at:
http://www.waynesthisandthat.com/pintographs.html
‘Pintographs’ are really harmonographs that use electric motors instead of pendulums to move a pen to
create detailed line drawings (Lissajous curves). Varying the motor drive systems and arm linkages will
create unique images. It's possible to have several sets of arm lengths for a pintograph machine so they
can be changed over to create different designs; and by carefully selecting the start & stop points or
stopping a drawing part-way through its drawing cycle an even wider variety of designs can be created.
‘Pintographs’ come in two basic forms, either the ‘Straight Arm’ or the ‘Scissor Arm’ type, each
producing similar images. The main difference between them being that the ‘Scissor Arm’ amplifies pen
movements to produce larger drawings in the same way as pantographs enlarge drawings. More
importantly, they also create designs radically different from anything produced by ‘Straight Arm’ types.
Both model variants are shown in illustrations on the next two pages.
The relative motion of the cranks (which must rotate at slightly different speeds) generate harmonic
relationships, with the pen being continually being moved along different paths bounded by four
extreme points. With Pintographs, the faster motor will eventually catch up with the slower one; so
drawn figures will eventually repeat themselves if the machine is left to run for long enough. Ideally
one motor should rotate one-tenth of a revolution faster than the other. Otherwise, if a pintograph
has both motors running at exactly the same speed, then they will push-and-pull the pen repeatedly over
the same path creating a (more-or-less) single solid line!
It's critical therefore to balance the speeds of the two motors. If the speed difference between them is
too great, then the lines will be so far apart that lines won't appear to flow smoothly; but if the motor
speeds are too close then the lines will be inclined to overlap as a solid mass of ink.
I decided to continue using my fairly successful pen holder clamp (shown in the illustrations of the
previous two models). You can experiment with you own pen holder ideas here very easily, just as you
can with the many variants of two-arm or four-arm (scissor) pivot points and crank positions. It is worth
noting here that all of your arm assemblies are a separate entity to the pintograph drive-unit described at
the bottom of the previous page - you just need to connect the two together - a suitable crank pin
attaching the drawing arms to the two drive wheels.
I did experiment with using screws (with plastic spacer washers and lock nuts) as the crank pins for my
early models but they were so tedious to undo each time that you wanted to separate the arms from the
drive-unit or to change crank pin positions that I substituted them for two of the longest (15mm) Plastic
Peg Rivets that I had. These worked surprisingly well, enabling me to extract them quickly and they
stayed in position (mostly) whilst drawing was in progress.
I also tried using Plastic Peg Rivets in lieu of screws and nuts to make quick-change pivot points for the
pintograph arms, but these became loose far too often; so (as you can see below) using screws with
plastic spacers and lock nuts on the arms is the only real option for model reliability.
The final problem to solve, was the height of the drive cranks. Because of the positioning of the motors,
the top of both drive wheels is approx. 60mm above the base of mBot’s chassis. I tried extending a pen
down through my pen holder clamp this far and whilst it did work, its leverage on the arms of the
Pintograph was excessive. The only solution was to make a purpose-built paper holding platform about
50mm high and the same dimensions as a piece of A4 paper (see the illustration below). A solid piece
of thick (18mm) plywood cut to match provided the top, this was supported on two strips of timber to
gain the height required. I then added two ‘Bulldog’ spring clips to hold the paper in place.
This worked very well and had the great bonus of firmly holding the paper steady whilst drawing.
Remember, the drive unit is a separate entity used to pull and push all variants of Pintograph arms and
for some arm combinations, the drive-unit would (thanks to the overall weight of the chassis assembly)
remain unmoved - but - for some combinations, the push/pull action of the arms would move the drive
unit about a bit. I could have connected mBot’s chassis (the drive-unit) to my wooden paper holder
somehow but this would have made the whole thing rather cumbersome and unwieldy to move.
I resorted instead (as you can see in the illustration at the bottom of the previous page) to adding a
weight to the top of mBot in the form of a block of steel (50 x 25 x 75) that I just happened to have.
This worked very well and stopped the drive unit from being moved by the action of the drawing arms.
Running mBot’s TT geared motors at 25% is the lowest you can go without them stalling; but under the
extra load from the pintograph arms (dragging a pen), my recommendation is to set one motor to 30%
which is about 2 secs per revolution (speed 76/255) and the second motor to 33% (84/255).
N.B. If there
isn't enough
weight on the pen, then it may lose contact with the paper, creating areas of the drawing which are too
lightly drawn, or even missing altogether. The position of the pen relative to the pivot point at the outer
end of the arms has an enormous influence on the drawing too. Many pintographs have their pens
slightly offset to one side of the pivot and pens can also be positioned inside or outside the pivot point.
Reducing the crank radius compresses the image whilst increasing the arm length stretches the image
left and right and compresses it top to bottom. Do experiment with all of these model concepts.
Begin by removing the protective paper from the diffuser plate and attach the plate to the LED matrix
board with four little plastic pegs (as shown above right) and then connect the LED panel to port1 of
mCore. The LED matrix assembly can then be attached with two M4 bolts to the robot as shown.
The mounting method shown in the illustration above is fine if you just want to give mBot facial
expressions (or ‘emotions’), but you must disconnect the ultrasonic sensor to fit it here, which is not a
good option in my opinion!
My own solution was to drill two 4mm holes @
15mm centres through a spare 4 x 2 stud Lego
building-block filched from Emma’s toy box.
See the diagrams on the left.
See the illustration above right. The LED Panel is quickly and easily removed for storage too (and for
disassembly I fitted the two M4 x 25mm bolts with M4 wing nuts). The Lego mounted LED Matrix
display can be easily fitted facing forwards, backwards or sideways on the studs on mBots cover and is
very useful when displaying feedback from the sensors. I use this a lot, but I’ve not seen any web or
other reference to anyone else mounting mBot components in this way.
MakeBlock’s LED matrix display board is described as 8 × 16 (read ‘eight by sixteen’), because there
are eight rows and sixteen columns of individual little Light Emitting Diode lights which can be turned
on and off using the ‘shows image’, ‘shows text’, ‘shows number’ and ‘shows time’ stack blocks.
Remember, you need to be on the ‘Devices’ tab to use these robotics blocks. If you drag any of the
‘show image’ stack blocks from the ’Show’ blocks category on to the ‘Scripts’ Area and then click on
the little box with the two blue oval ‘eyes’ showing then it opens-up the edit ‘Panel’ (see below):
Try making this and the variant shown below. It too shows
the same four simple ‘eye’ graphics, but this time it uses a
different stack block which includes a timer (also set to
1/10th second).
There are two that can be used to display user or script generated text (upper or lower case BUT only
three characters at any one time. You can try experimenting with the middle of the three blocks shown
above, changing the values in the x: bubble window. Try giving x: the value ‘2’. You will find that this
puts a two-character message e.g. ‘Go’ in the centre of the LED matrix panel.
You can use these ‘offset value’ settings to usefully ‘scroll’ much longer pieces of text across the LED
panel using an (x = x - 1) repeating loop. An example of this is shown at the top of the next page. You
will see that it moves the text (rather slowly) to display any message longer than three characters. It
needs a very short (0.01 sec) ‘wait’ block timer inserted into the script to allow the LED Panel time to
refresh itself - and it will not work without this short pause! You can also try something similar (see the
next page) by using a (y = y + 1) repeating loop to ‘scroll’ text downwards.
If you insert numbers into the ‘shows text’ stack block then you can offset the position of those numbers
by inserting a suitable value into the (x:) window; but you can only show up to three characters doing
this - but useful perhaps if you want to centrally position just one or two digits.
Do remember though that the generally much more useful ‘shows number’ stack block displays up to
four numbers.
The 8 x 16 LED Matrix display ‘Panel’ can be a very useful output device - that is until you can get your
hands on the rather desirable Me 7-Segment Display module which will do a similar job so much better!
I didn’t think much to it, but she thought that it was brilliant and created loads
more images to try. The LED Matrix display ‘Panel’ really got Emma into
thinking about scripting for herself - what a result!
It was not possible to add this sound file into the mBlock 5 script shown above (because sounds are only
possible when they are called by a ‘Sprites’ tab script) - and here we are on the ‘Devices’ tab!
… I switched to the ‘Sprites’ tab and uploaded the same sound file into my ‘Sound Library’ and created
the two-block script shown above left. Next I returned to the ‘Devices’ tab and added the three blocks
shown above right to the main countdown script listed at the top of the page.
I positioned these three blocks below the ‘repeat’ loop and above the ‘clears screen’ stack block. (The
‘wait’ 2 seconds block has been added here to match the length of the sound file, so that Emma’s
‘Firework’ image is ‘extinguished’ as soon as the ‘bang’ sound file ends).
The script shown at the top of the next page uses a Variable named ‘Distance’ to take the reading from
the ultrasonic sensor and convert it into millimetres. It then displays (in real-time) the reading as
continuous feedback on both mBlock’s ‘Stage’ and on the LED Matrix ‘Panel’.
This is a shorter script, but it does make sense to (and I always do) store feedback data in a Variable; so
out of the two scripts above, my preference is for the first one.
This animation script also makes use of the Variable created earlier, called ‘Distance’ and some complex
nesting of blocks.
It uses the ‘Reporter’ block, ‘Round’ from the ‘Operators’ blocks category twice to produce an integer
for the y value position which decreases the closer the sensor gets to an object.
The LED Matrix ‘Panel’ starts by showing nothing and then as the y values decrease it begins to show
the image scrolling upward a row at a time. The full image is displayed when ‘Distance’ = 0 and if
‘Distance’ (the sensor value) starts to increases once more then the image begins to scroll back down
again.
You need to create a user-defined block (see pages 41, 42 & 64)
for more on this). Call it ‘Scroll_Text’ and add two input
settings when it is defined; a string input called ‘Text’ and a
number input called ‘Delay’.
This is a marginally complex script, but it’s definitely worth experimenting with this concept.
Finally, we updated (very early on in our programming journey) Emma’s favourite self-programmed
games at that time, “Dice” and "Rock / Paper / Scissors" to take advantage of our newly purchased LED
Matrix display panel.
The script at the top of the next page is an updated version of our earliest attempts at the "Rock / Paper /
Scissors" game. Here the script sets another 'Random' Variable - this time, a random number (between 1
& 3) and based on this number will select from a list a matching graphic to display on the LED panel.
The concept of ‘Lists’ is featured on page 68. This page describes the use of a ‘Useful List’ lookup table
containing:
1 Rock
2 Paper
3 Scissors
The mBot Servo Pack is an ‘add-on’ (3-models-in-1) kit. The MakeBlock advertising blurb for this
pack says that you can, with the components it contains, construct either a ‘Dancing Cat’, a ‘Head-
Shaking Cat’ or a ‘Light-Emitting Cat’. It suggests that these additions make the robot more enjoyable
and benefit children's creative thinking.
The information contained in this pack is however minimal! Nevertheless if you buy it from China, it is
an absolute bargain! Mine arrived trouble free in only four days and only cost approx. £10 inc. free
postage via Royal Mail.
The little manual that comes with the pack essentially only shows a sequence of graphics (very similar in
style to the original mBot manual) showing how to modify mBot to create the so-called ‘Dancing Cat’
model. Sadly, construction details of the other two models are NOT included here. It is not as
enticing as it sounds either; the servo unit is used in this model to just waggle a 16mm length of cuttable
linkage up and down in a see-saw motion suggesting ‘waving paws’.
There is also a diagram in the booklet showing the fitting of the Micro Servo on to its Bracket Plate and
then fitting the Servo Arm - but the booklet contains no information on how servos work or how they
should be tested or safely operated. Much more importantly, there is no hint of how to programme
any of the three models. However, after much on-line searching and false trails I eventually solved
the whereabouts of the elusive instructions - see pages 196 & 197 for more on this.
BUT - having said all of the above, you do get an awful lot of bits for your money in this add-on
pack. The most useful aspect of buying it (almost certainly) is the gaining of the extra construction bits
that you will enable you to experiment with your own robot creations. Everything that the pack contains
is laid out below):
The most useful addition to your toolkit is probably the Mini-Spanner (or ‘Wrench’ as MakeBlock
describe it). This complements the excellent double-ended (Posi-drive & 2.5mm Hex) screwdriver that
comes with the original mBot kit and most importantly now allows you to tighten up the fastenings on
your robot kit without needing to hold the nuts with pliers!
Why, oh why was it not included in the original kit rather than having one distributed in every add-on
pack (meaning that I now have four!)? The spanner/wrench has a 5mm A/F slot at one end and a 7mm
A/F slot at the other; this end is a little loose, but OK for M4 nuts. There are three more holes for
smaller sized nuts situated in the body of the spanner.
In this add-on pack’s component parts are several shiny anodised (Makeblock blue) plates, brackets and
cuttable linkages. There are two 3-hole x 3-hole Right-Angle Brackets, two 9-hole x 2 Slotted Plates
(Code I1) and four 160mm lengths of 20-hole (cuttable) Linkage. There are also four M4*25 brass
extender studs (identical to the four that raise mCore above mBots battery pack in the original robot kit).
These are so useful for spacing both Me boards and component parts anywhere in a construction.
20 × M4 x 8 Screws
10 × M4 Nuts
6 × 2mm x 7mm dia. Plastic Spacers
2 x M2 x 10 Screws & Nuts (for attaching the Servo to its Bracket Plate)
2 x 2.2 x 6.5 self-tapping Screws (for attaching Arms to the centre of the Servo spindle)
2 x 2.2 x 8 self-tapping Screws (for attachment of linkages to Servo Arms)
Whilst this is nothing to do with servos, you get one Me series RGB-LED V1.1 circuit-board module
which has 4 little (but full colour) ws2812 RGB LEDs. This is needed for the ‘Light-Emitting Cat’.
model. With the modules own integrated chip you can control each little LED individually from your
programmes to adjust both brightness and colour by mixing different amounts of red, green, blue light.
Finally, you get the important bit, the 9g Analogue Micro Servo set (one Servo complete with 3
different Servo Output Arms, a rectangular Servo Bracket Plate and a circular Arm Attachment Plate).
Servo output arms are sometimes called ‘servo horns’ and have a specific spline size - this pack contains
a single-ended horn, a two-point (double-ended) horn and four-point (unequal lengths) horn.
To connect the servo you also get one Me series RJ25 V 2.2 Adapter circuit-board which converts mBots
standard RJ25 connector to two common signal connectors (for controlling two servos). This board
contains both a power interface and a signal interface and is used to connect the supplied Micro Servo to
mCore via a 6P6C RJ25 (20cm) cable. You get two of these cables included in the pack. This adapter
can also be used to connect other suitable Me series modules such as the Me Temperature Sensor
module.
A servo is a type of motor that can be used in many ways. They consist of a potentiometer and a motor
connected to the output spindle, using built in circuitry to accurately control angular movement of the
spindle. The output spindle can be positioned to specific angular positions by sending the servo a signal
of how far to turn. Small servos have traditionally been used in radio-control applications to position
the control surfaces (elevators & rudders) to fly model airplanes or to control the power and steering of
model cars.
So, all-in-all, that’s a lot of stuff for a tenner or thereabouts and the circuit boards & cables if bought
individually would add up to much more than that alone - as I said earlier, it doesn’t seem to be well
supported with paperwork instructions, but nevertheless this pack is an absolute bargain!
My own design concept for the ‘Dancing Cat’ model requires a second servo to raise its tail! - (see page
nnn). I intended to buy another of these bargain servo packs to double the parts that I have just
described on the previous page (the Adapter circuit-board would be surplus to requirement since one
board can drive two servos) but at the price, still worth it to gain a second servo and all the other bits!
Sadly, about a month later when I tried to get a second pack they were sold out and unavailable (I’m not
surprised at this price). Eventually (about two months later) I did get another Servo Pack; this time for
£15 inc. UK postage - but I still consider this to be a bargain!
Remove the protective paper from the rectangular Servo Plate (which is made from beautifully machined
acrylic).
Next, I selected a 9 hole x 2 I1 Slotted Plate and bolted a 3-hole x 3-hole Right Angle Bracket to its
centre using just two M4 x 8 Screws and Nuts in the frontmost holes only. To this assembly I added a
second 9 hole x 2 I1 Slotted Plate mounted on the inside if the angle-bracket with two more M4 x 8
Screws and Nuts. I bolted the RJ25 Adapter circuit board on one side of (and at right-angles to) the first
horizontal, I1 Slotted Plate. The adaptor was mounted next to the angle-bracket using just one M4 x 8
Screw and Nut in the hole closest to the angle-bracket (leaving the outer hole free for use later).
I then added two M4*25 brass extender studs to the second (vertical) I1 Slotted Plate using the fourth
pair of holes (the ones just above the angle-bracket) securing them in place with two M4 Nuts.
Onto these two extender studs, and using two slightly longer (M4 x 14) Screws, I was able to mounted
the Servo Plate; with the Servo body fixed horizontally as shown in the diagram above - the screws
passing through the two slots in the acrylic plate
You must zero the spindle before you fit one of the servo
arms. You can then position the servo arm on its splines
setting its zero-position angle according to the nature of the
task that you intend to carry out.
So at this point, and only now, should you attach one of the
white Servo Arms supplied (as shown in the diagram on the
right). Use a 2.2 * 6.5 self-tapping Screw to attach the arm to
the centre hole in the Servo spindle (once again, these are
very hard to manipulate with large (or very small and
inexperienced) fingers.
• Remember, the Micro Servo unit can rotate its Arm through approx. 180º and no further.
• Do beware too that the 9g Analogue Micro Servo supplied in this add-on pack is not as
strong as a standard radio-control servo (but its fine for mBot models if treated
carefully).
• The Arm only grips the Servo’s spindle by small splines in the plastic, so it can be
damaged (as can the Servo motor itself) if too much force or leverage is applied.
“Our daughter received her first expansion pack today and there are only
directions for one option, the dancing cat. She wants to do the head-shaking cat,
but there are no directions. Can you please help?”
Eventually after much on-line searching and false trails I found the model making instructions for
‘Dancing Cat’ and the missing instructions for the other Servo Pack models (the ‘Head-Shaking Cat’
and the ‘Light-Emitting Cat’). At the time that I was looking (mid-2018) these were well hidden in the
Makeblock website; but they are now more easily identified, and you can find these files fairly easily
yourself using the following link:
http://learn.makeblock.com/en/mbot-add-on-packs/
mBot 动感扩展包_程序示例.rar which (using Google Translate) equated to MBot dònggǎn kuòzhǎn
bāo_chéngxù shìlì and translated as: “ mbot Dynamic Expansion Package _ program example.rar ”.
When the file was processed by ‘7-Zip’ it extracted a folder with the same name (mBot 动感扩展包_程
序示例) and this folder contained three mBlock 3 (.sb2) project files - but were they in the same order
as the building instructions? On examining these mBlock 3 files I was delighted to see that the script
blocks were the English language versions, but the comments call-outs describing them were in Chinese.
I was probably hampered a bit with the Chinese to English translations of both the filenames and the
comments contained within the files and in retrospect I now know that the contents of the downloaded
Program.rar file, are not in the same order as the downloaded Building Instruction .pdf file.
I was now able to load these three .sb2 files into mBlock 3 and edit the comments. The first comment
call-out from the first ‘The Kitten Looking Around’ file that I translated had the following flowery style:
“This program according to the angle of the servo installation is different, need to adjust the servo
angle value”. Not over-clear, but enough for me to work on to create rather more understandable
English translations. The translated comments for all three models were all very much in a similar vein,
but some more understandable than others.
The three files extracted from the download are itemised on the next page, whilst the mBot
modifications required to make the three ‘Cat’ model projects (the building instructions) and the
necessary mBlock 5 programmes to control them are described in the next three appendices.
File 1: 东张西望的小猫.sb2 - which equates to: Dōngzhāngxīwàng de xiǎo māo.sb2 and translates as:
‘The Kitten Looking Around.sb2’
This file contained a large complex script headed by an ‘mBot Program hat’ block (signifying uploading
it to Arduino for ‘Off-line’ use). It has a 'disco' stage backdrop & a single sprite (named ‘mbot’). The
false impression given by the ‘Stage’ background graphics - ‘a disco, with lights’ confused me!
It took me some time to work out that this file was actually the ‘Head-Shaking Cat’ programme
(although I thought on first viewing that it might, thanks to the ‘disco’ lights look, be related to ‘light-
emitting’). This was the second model in Makeblock’s sequence of building instructions
File 2: 小猫探照灯.sb2 - which equates to: Xiǎo māo tànzhàodēng.sb2 and translates as:
‘Kitten Searchlight.sb2’
‘Searchlight’ was the clue here! This seemed to be the ‘Light-Emitting Cat’ programme and the file
had lots of scripts which were mostly activated by keyboard single keypresses; but there were two
slightly longer scripts and some comments referred to a ‘tail’ and ‘lights’:“ Press the space bar, the
kitten rotates to the right and swings the tail” and “Release the space bar, the kitten stops rotating, the
servo angle is reset, the light goes out”. This was the third model in the sequence of building
instructions.
File 3: 跳舞的小猫.sb2 - which equates to: Tiàowǔ de xiǎo māo.sb2 and translates as:
‘Dancing Kitten.sb2’
This seemed to be the ‘Dancing Cat’ programme, the names matched, although the file contained just
one short programme (also starting with an ‘mBot Program hat’ block).There was a self-defined block
script called ‘servo’ which used a repeat loop to swing the arms 5 times and a comment: “If someone is
close, and the distance is less than 20cm, then it swings the arm and turns left and right in welcome”.
This was the first model in Makeblock’s sequence of building instructions.
Now, in 2019, and with totally new mBlock 5 software I have had to totally rewrite the files and whilst
these owe much to the original concepts, they do look totally different and I have added (as you will see)
several modifications of my own.
Why Cats? …
The "Chinese Lucky Cat" is a cat figurine, often with an automated slow-
moving single paw, which waves and beckons customers; these are usually
displayed at the entrance of shops, restaurants and other businesses.
This figurine is however Japanese, and it’s called the “maneki-neko” the
no copyright ‘beckoning cat’, which is a common Japanese lucky charm or talisman no copyright
infringement believed to bring good luck to the owner. infringement
intended intended
I have already outlined my version of modifying mBot to build the ‘Dancing Cat’ mBot model in
Appendix 2, but the enclosed instructions start by suggesting that you disconnect the cable and remove
the Ultrasonic Sensor from the front of mBot to create the “Johnny 5” look (he’s the robot in the film
“Short Circuit”).
You can do this if you want to, but I quite like leaving the sensor where it is - this makes less work to do
if you want to switch models frequently and the concept of moving the sensor to the top of a ‘neck’
(which you are about to build on top of mBot) is only to suggest that the Ultrasonic Sensor receptor
tubes are the ‘cats eyes’ above the ‘waving paws’ - and I had a much better idea for the ‘paws’!
Step 1. Replace the two rear screws holding mCore and its
cover down on to the rear two brass pillars and add two additional brass pillars
(shown in the diagram above right) to secure mCore to the two lower brass
extender studs.
Step 2. Assemble one of the 3 x 3-hole
Right Angle Brackets with one of the 9-hole
x 2 (Code I1) Slotted Plates (as shown in the
diagram on the right) using two nuts and
bolts - note which holes are used for this.
The second screw through the adapter board will need a nut to secure
it on the underside of the slotted plate.
Step 7. Attach one of your 20-hole (cuttable) Linkages to the Servo Arm using two 2.2 x 8 self-tapping
screws passing through two of the 2mm plastic ring spacers (see the diagram below):
Beware, it’s very easy to drop these little screws, they are so tiny for big fingers and you only have 2
(and no spares!). I didn’t find the supplied screwdriver the best fit into the cross-head of these screws,
so I used another (a jewellers screwdriver) from my collection. I do strongly recommend screwing each
screw into the third-hole-out from the centre first, so that it taps a thread into the hole in the servo arm
and thus becomes slightly easier to fit a second time when you attach the Linkage later.
Cuttable Linkages have 20 holes, therefore there is no centre hole equidistant from each end. I suppose
that you could cut off a single hole unit from one end leaving 9 holes evenly spaced either side of a
central hole (and leaving a single hexagonal washer). But cutting a length of Linkage’ isn’t really
necessary for this model, since it still works even though the arm is slightly unbalanced. I did however
decide to cut one length of Linkage into two 9-hole lengths & 2 hexagonal washers. (See page 200).
You also need to connect the Servo to slot2 of the RJ25 Adapter
board - slot2 is the left-hand one of the two signal connectors when
looking at the end with these two connectors. My own ‘test rig’
variant on the theme of
the ‘Dancing Cat’ model
is shown in Appendix 2
(on page 195).
Positioning the second cut Linkage piece on top of the first one
(with a 90º angle between the two) I used two M4 x 15mm
Screws, two 2mm plastic spacers and M4Nuts together with
my two little hexagonal offcuts as spacer pieces between the
second top short Linkage arm and the plate (but these could
have been two more of the 2mm plastic spacers instead). See
the illustration of the modified ‘arms’ on the left.
I had seen
somewhere on a
website the ‘Dancing Cat’ model with two small ‘hands’ cut
out from cardboard and attached to either end of the full
length of 20 hole Linkage attached to the Servo Arm (see a
picture of this below).
I thought that I could make a
much better attempt at this
and took a suitable picture of
Emma’s cat ‘Ko-Ko’. I edited
the picture extracting a ‘head
shape’, a ‘tail shape’ and a
‘paw / leg’ shape (which I
duplicated and ‘flipped’ to
make a second paw).
Modifications to mBot for the ‘Dancing Cat’ model very nearly completed; it was time to programme it.
Project Concept: The ‘Cat’ sits waiting but raises its ‘tail’,
‘meows’, waves its 'paws' and dances excitedly from side-to-side in Start
welcome if it detects someone close to it.
Set both servos
Shown on the right is a Flow Chart algorithm that I created to to 90º
analyse the logical processes required to achieve the objectives of
the above concept:
If
A cat raising and lowering its tail is a very common gesture of Ultrasonic Sensor
< 600mm
greeting. Since I had now bought two Servo packs I was able to
fully utilise the second of the signal connectors on the adaptor
board (now attached to mBot) by adding my second servo to
emulate this tail movement. Play ‘Meow’
sound
Set Motors to
twist Right (45º)
Set Motors to
twist Left (45º)
Move servo
‘Paws’
Set Motors to
Spin Around
(360º)
Play ‘Meow’
sound
The second Servo was attached to slot1 on the adaptor board and Lower ‘Tail’ servo
the servo arm mounted vertically on its splined shaft. DOWN to (0º)
My modified and adapted ‘Dancing Cat’ programme (on the ‘Devices’ tab):
Unbolt the 3 x 3 hole angle-plate and the upright slotted plate that held the servo too. The horizontal
slotted plate at the back of mBot can be left in place, as can the RJ25 Adapter Module, leaving it
attached and ready for reconnecting the servo later.
I used a small pair of snipe nosed pliers to hold the nuts whilst the screws were tightened with the
hex-drive screwdriver.
All you need to do now is to remake the RJ25 connections required for this model. The ports used in the
downloaded demonstration programme use port3 for the Ultrasonic Sensor and port4 for connecting the
Servo Adapter module.
Since the ‘Dancing Cat’ model used port4 for the Servo Adapter then there is nothing to change here.
The initial setup of mBot had the Me Ultrasonic Sensor connected to port 3 (as used in the ‘Dancing
Cat’ model) so I suggest keeping that connection and adapting the programme accordingly, leaving the
line follower module connected to port2 whilst port1 remains empty.
Construction of the ‘Head-Shaking Cat’ model completed; it was time to think about transcribing the
‘The Kitten Looking Around’ Makeblock programme file that I had downloaded for this project. This
was the rather complex looking (mBlock 3.sb2) file described in Appendix 2 on page 198 and shown in
its entirety on the left-hand side of the next page. The mBot model worked very well using mBlock 3.
Transcribing a new version this file in mBlock 5 was not too difficult and considerably easier than I
thought it might be. It worked the first time that I tried it, operating the mBot model in exactly the same
way as if using the original script. The transcribed .mblock file is shown on the right-hand side of
following page and as you will see, they do look very similar.
In the process of transcribing the mBlock 3 file into mBlock 5 format, these long sequences of nested
decisions became easier to understand which allowed me to break it down into much smaller scripts.
The ‘cat’s head’ starts off looking forwards (the sensor in the middle position). When the programme
is activated, the cat’ moves forwards rather hesitantly for approx. one second, it then pauses to ‘look’
first right, then centre and then left by moving the sensor from side to side using the servo.
If no contact is detected by the sensor (within a given range) then the ‘cat’ continues to move
forwards as before. When the moving ‘head’ detects a contact it stores the Range in a variable) then
it makes a decision of what to do next based on pre-defined ‘a contact is close’ or ‘a contact is very
close’ parameters.
If the head turns to the left and detects something within range then the ‘cat’ backs away and turns
right. If the head turns to the right and detects something then the ‘cat’ backs away and turns the
opposite way (to the left).
To emulate this in mBlock 5 I broke up the original script that I had transcribed into nine clearly
descriptive self-defined ‘My Blocks’ scripts, named as follows: ‘Head_Feedback’, ‘Make_Decision’,
‘Move_Backwards’, ‘Move_Forwards’, ‘Move_Timer’, ‘Pause_Timer’, ‘Poll_Range’, ‘Turn_Left’ and
‘Turn_Right’.
I also created three Variables to store the readings from the Ultrasonic Sensor every time that it was
polled. These were sensibly named as: ‘Range_Centre’, ‘Range_Left’ and ‘Range_Right’.
This script is shown on the next page along with four simple scripts which will enable you to manoeuvre
mBot manually using the four cursor keys on the keyboard.
It is easily
changeable and
is added to
briefly pause
script sequences
to give mBot
(mCore) time to process or store data.
The two remaining self-defined block scripts (‘Poll_Range’ and ‘Make_Decision’) and called in the
‘forever’ loop part of the ‘mBot start’ script, are all shown on the next page.
The self-defined ‘Poll_Range’ block checks and then stores the feedback from the sensor
at three different (‘Range_Left’, ‘Range_Centre and ‘Range_Right’) head positions.
Once I had created the ‘tidied-up’ version of the original ‘The Kitten Looking Around’ Makeblock
project file (as described in Appendix 2 on page 198 and shown on page 207) I thought that I might be
able to improve on the rather irksome ‘move, pause, look-around, move again etc.’ sequence of the
original project and I had my own ideas about how I might create a viable alternative.
When I first worked on my version of this project (initially using mBlock 3) it made considerable sense
to use the versatile ‘Events’ > ‘when (space) key pressed’ / ‘released’ hat blocks to control the
programme so that mBot could be stopped easily if it got into trouble. But the ‘when (space) key
released’ block now no longer exists! Now converted to mBlock 5 format, my programming scripts
mostly work as I expected and are fairly understandable sequences.
I did however find that the ultrasonic sensor feedback into ‘Proximity’ was occasionally not good when
mBot was heading at a shallow approach angle towards a wall or other major obstructions. Whilst this
programme did work, I found that it was not quite as reliable as the transcribed original ‘The Kitten
Looking Around’ Makeblock file (described in detail on pages 211 to 215).
My own Project Concept for the ‘Head-Shaking Cat’ (mk. II) - in mBlock 3 was:
The ‘Cat’ moves for as long as the SPACEBAR on the keyboard is depressed. It moves forwards
shaking its ‘head’ from side-to-side until it detects something close to it – the ‘cat’ then chooses to
turn randomly to either to the left or to the right and only stops if the SPACEBAR is released.
I also decided that I needed a self-defined block function ‘Set_Turn’ which would use a random number
(0 or 1) and turn this numeric decision into understandable text, “LEFT” or “RIGHT”, and then store
the textual direction to turn in a variable called ‘Random_Choice’.
I also needed a second block function ‘Make_Turn’ to make the decision when to turn, and which way to
turn, using the following piece of logic:
If ‘Proximity’ is less than ‘Avoid_Distance’ and ‘Random_Choice’ contains “Left” then turn LEFT
else
If ‘Proximity’ is less than ‘Avoid_Distance’ and ‘Random_Choice’ contains “Right” then turn RIGHT
To start programming this model you first need to make three descriptively named Variables
‘Avoid_Distance’, ‘Proximity’ and ‘Random_Choice’. The use of these names will help to make your
scripts clearly understandable. You also need to make four self-defined ‘My Blocks’ - ‘Make_Turn’,
Move_Sensor’, ‘Set_Proximity’ and ‘Set_Turn’. Not only will they break the programming concept into
small, easily understood chunks, but these names will also help to make the whole programming
sequence clear.
Eventually I decided that the best way to start and stop the ‘Head-Shaking Cat’ was by using two
separate keypresses. Not as good as holding and then releasing a single key, but as a workaround this
solved the loss of the ‘when space key released’ hat block.
I added the same ‘mBot stop’ script (activated by the spacebar) and the four manual control scripts
(using the cursor keys on a keyboard) that I had created for my ‘Head-Shaking Cat’ (mk. I) project (see
page 209). The ‘up arrow’ cursor key is ‘mBot forward’ whilst the ‘down arrow’ cursor key is ‘mBot
reverse’, the cursor key ‘left arrow’ is ‘mBot left’ and the cursor key ‘right arrow is ‘mBot right’.
Shown below are the four self-defined function blocks called by the main ‘when (0) key pressed’ hat
block script (described and shown on the previous page).
I found that if my mBot ‘cat’ was trapped in a corner or heading at a shallow approach angle towards a
wall or other major obstruction then I needed to quickly hit the ‘Spacebar’ to active my ‘mBot stop’
script which stops and resets everything!
I was then able to turn or reverse mBot out into open space once more by using one or more of the four
cursor key manual control scripts.
Whilst this programme worked, I found that it was not as good as the original Makeblock project file
‘The Kitten Looking Around’ which had the hesitant stop-and look-approach (see pages 206 to 210).
You can see from the picture on the
right that for both the (mk. I) and the
(mk. II) models I modified mBot’s
‘eyes’ (the ultrasonic sensor based
moving ‘head’) by adding a cat mask
over it.
Once again, I left the protective cover in place over the top of mCore. The 9g Micro Servo should still be
on its mounting plate - but this time it needs the servo arm to be repositioned horizontally (as it was for
the ‘Dancing Cat’ model) - not vertically as for the ‘Head-Shaking Cat’’ model.
I found that holding the screws with small snipe-nosed pliers helped here.
Reconnect all the Me components to mCore. You can use other ports for this project if you wish,
however it makes sense to leave the infrared emitting & receiving LED line-following module connected
to port2 and the ultrasonic sensor connected to port3 (exactly as they were in the original mBot
configuration). The Me RJ25 Adapter module should once again be connected to port4 and the servo
connected to slot2 of the adapter board. That leaves port1 available for connecting the RGB-LED
module (the cat’s flashing tail) using another 6P6C RJ25 Me cable.
The ‘Light-Emitting Cat’ mBlock 3 (.sb2) file downloaded from Makeblock and described in Appendix
2 on page 198, was also not very inspiring (see the complete set of original scripts for this below-left).
Having played
with this
programme in
mBlock 3, I
didn’t think it
worth it to
transcribe any of
these scripts into
mBlock 5 format.
As hinted at on
page 214, I
thought that it
would be much
better if could use
the scripts created
for both moving
mBot and turning
the head in the
‘Head-Shaking
Cat’ mk. I project
in Appendix 4.
All I needed to
do, I thought, was
to duplicate this
file and add a
couple of new
self-defined
blocks.
Particularly a
script to
randomly flash
the Me RGB-
LED module
lights.
I would also need to add very similar tail-raising and tail-lowering blocks to those created in my
‘Dancing Cat’ project. So, I loaded my ‘Head-Shaking Cat’ project file into mBlock 5 and immediately
saved it as a new project file called ‘Light-Emitting Cat’; but before continuing with any programming I
had to reconfigure mBot.
If you are moving on from the ‘Head-Shaking Cat’ model described in Appendix 4 (and I assume that
you are) then there is very little to do in terms of any modifications needed to turn mBot into the new
model.
I only needed to add four new ‘My Blocks’ to the new ‘Light-Emitting Cat’ project. These self-defined
blocks were called ‘Tail_Raise’, ‘Tail_Lower’, ‘Tail_Leds_On’ and ‘Tail_Leds_Off’ and are shown in
entirety below:
The four little ws2812 lights on the RGB-LED module are set to
show random colours each time that the ‘Tail_Leds_On’ script
is called.
The ‘Tail_Leds_Off’ script conversely sets the three numeric permutations (for all four of the little
ws2812 LED lights colours) to zero - which means no light is emitted at all.
Addendum re ‘Cats’
By now, I was getting slightly fed-up with ‘Cat’ models - but I had completed the last one and had
ended up with four complete ‘Cat’ projects. After the confusion over their names (see page 198) it now
seemed to make sense (to me anyway) to totally rename them as follows:
‘Dancing Cat’ - this project I renamed as ‘Happy Cat’
‘Head-Shaking Cat mk. I’ - this project I renamed as ‘Cautious Cat’
‘Head-Shaking Cat mk. II’ - this project I renamed as ‘Inquisitive Cat’
‘Light-Emitting Cat’ - this project I renamed as ‘Colourful Cat’
Re. the Me RGB-LED module used in the ‘Light-Emitting Cat’ / ‘Colourful Cat’ project; Appendix 11
on page 233 discusses the basic principles of testing and experimenting with LEDs in detail.
This was certainly needed for the ‘Dancing Cat’ model - but
not for the other models; so what if this rather unsightly
assembly was removed altogether and the RJ25 Adaptor
mounted on another ‘Lego’ block that could be positioned
anywhere on the studs at the front end of the transparent case
covering the mCore board.
Another trip to Emma’s
toybox was needed! The resultant
mount (exactly the same as the one described in Appendix 1 on
page 184) is shown above-right.
The mBot Six-Legged Robot pack is another add-on 3-models-in-1 pack for mBot. The MakeBlock
advertising material for this pack says that you can construct either a ‘Beetle’, a ‘Mantis’ or a ‘Crazy
Frog’ with the components in the pack and suggests that these additions make the robot more enjoyable
and benefit children's creative thinking. Information in this pack (see below) is, as usual, fairly minimal
- bought in the UK it cost me £18 plus a marginally steep £3.50 p&p (but it did arrive the next day!).
The advertising blurb also has flowery descriptions - the primary model, a ‘walking hexapod’, is
described as “a six-legged Beetle that can turn around quickly to attack an enemy” and a second model
“The Mantis quietly crawls, waving two arms and is a hunter from the darkness”. It also describes the
third model as “the little crazy Frog which dashes around so madly that nobody can stop it”.
The little manual that comes with the pack shows a sequence of graphics similar in style to the original
mBot manual; these images only show how to modify mBot to create the so-called ‘Beetle’ and
construction details of the other two models are not included. Much more importantly, and as
disconcertingly as before, there is no hint of how to programme any of the models using mBlock.
But now that I knew where to look - thanks to searching previously for the elusive Servo Pack
Instructions (see pages 196 & 197). I found the complete model making instructions and some
programming examples on the Makeblock page describing add-on packs that I had visited earlier using
the following link:
http://learn.makeblock.com/en/mbot-add-on-packs/
The programming files were once again stored as RAR files, so as before, I used 7-Zip to decompress
them. On examining these mBlock files I was delighted to see that everything was in English including
the comment callouts attached to some of the blocks in the scripts - they were written in English, but (as
before) needed some thought to clarify the meaning!
The enclosing box was the usual size, shape and style for these add-on packs and on first-opening, was a
little underwhelming since it contains no new Me Modules (but I was expecting that!). This add-on pack
once again contained the useful Mini-Spanner (Wrench) - so I now have 3 of these!
In the box too there was a huge bag of assorted (and very useful fasteners) but the most exciting and
useful contents were undoubtedly the 12 shiny anodised blue beams and plates which matched my own
mBot. I now had at my disposal enough constructional bits to experiment with my own models, so
buying this add-on pack is certainly worth it for the contents alone and not particularly for building the
models specified.
In detail, the beams and plates contained in the pack are as follows:
Two 11-hole, 108mm 0412 Beams (see the next page for the blue/red coding here).
There are two 10-hole, 92mm 0412 Beams; six 9-hole, 76mm 0412 Beams and two 7-hole, 60mm 0412
Beams. There are also two seven-hole 45° Plates - you may have gained one of these already, if like me,
you have bought (or will buy) the ‘Light & Sound’ Add-On Pack.
Every component in the ‘Six-Legged Robot’ add-on pack is shown laid out in the picture above.
Below is a list of the many fasteners you get in the pack. Do note that once again there are several more
of these than actually specified by Makeblock!
10 × M4 x 8 Screws
20 × M4 x 14 Screws
10 × M4 x 22 Screws
4 × M4 x 30 Screws
4 × M4 x 35 Screws
10 × M4 Nuts
20 × M4 Nylock Nuts
20 × 3mm x 7mm dia. Plastic Spacers
12 × 10mm x 7mm dia. Plastic Spacers
24 x Plastic Peg Rivets (4mm dia. x 15)
N.B. The Plastic Peg Rivets together with 3mm thick spacer washers can be used in lieu of screws and
nuts as movement pivots to speed up model building & experimentation with your own projects (but be
advised that for model reliability, using screws with lock nuts is a much better option).
In truth I was looking forward to this add-on pack very much. Especially gaining the Beams to use in
my own creations. I thought that ‘walking’ robot models might be good value too and entertaining
though they were, they were also rather boring after a few goes with the IR remote control. Sadly, there
is not really any scope for mBlock Scratch programming with these models other than Emma’s wishful
idea for using the sound sensor to get the ‘Frog’ to jump on command - something we decided that was
just not worth it; so (and at variance with the advertising blurb) there was very little here to inspire
Emma into any really creative thinking.
If you are starting with a completely built mBot then you will
need to disassemble the front wheel and Me Line-follower
Sensor assembly. Store the front wheel unit somewhere safe
for rebuilding mBot later. Remove the two wheels and remove
their tyres - store the tyres somewhere safe too (& do not lose
the two little self-tapping screws).
N.B. If the joint is too loose, the leg might jam, and mBot will
not be able to walk easily; but if the joint is too tight, then
mBot won’t be able to walk at all!
On top of that, place an 11-hole, 108mm 0412 Beam, passing the screw through the end hole as shown
in the sequence below. On top of those two Beams add a 9-hole, 76mm 0412 Beam using an end hole
once again. You can now use an M4 Lock Nut to secure these three Beams to the Wheel - remember,
not too tight & not too loose!
Your wheel assembly and the leg linkages that you have created so far for the left-hand side of mBot
should look like the diagram below:
M2.2 x 9mm
Self-Tapping Screw
Do remember for all of your Linkage joints - make them not too tight & not too loose!
It is not too difficult a task to repeat a mirror-image construction of the left-side linkage to create the
linkage for the right-side legs of the ‘Beetle’ - but do note the comment about the ‘crank’ Screw position
below. You should find this second side to be a much quicker assembly time. In reality, I mirrored the
construction as I added each component - first the left-side component and then the maching right-side
one.
N.B. Once I had made up the wheel for the left-hand side of the ‘Beetle’ I copied its construction to
match the position of the three linkage Beams to be added to the right-side wheel but making sure that
the Screw providing the ‘crank’ was in a mirror image position (i.e. it was on the left side of the
central axle hole not on the right of centre like the red dot in the diagram illustrating the left-side).
This all worked very well, but it probably took about an hour altogether to construct this model. This
has been the longest construction time for any add-on model so far - but was it worth it? Remember, it’s
important to find the balance between loose & tight with the linkages and perhaps check the joints every
time you operate it. Remember too that if the joints are too loose the legs will jam and mBot will not
walk. If the joints are conversely too tight then mBot can’t walk at all. I used the principle of screwing
them tight till they were solid and then unscrewing them for half-a-turn, which seemed to work well.
Was it worth it? Yes, I think that it was - just - if only for novelty value and, for Emma’s benefit, a
demonstration of linkages and rotary & linear motion. Sadly, there is little that can be done with the
model apart from watching it walk. Any project scripts that you have written to control mBot can be
used to control the ‘Beetle’ variant but there is no need for any new scripts to be written to control it.
You could, but I think that controlling it with the IR remote in ‘manual control mode’ is what is
intended. It seemed totally pointless for the instructions to specify modifying the line-follower sensor
position on the front of the model since the model only vaguely works in this mode until the ‘Beetle’
needs to turn, which it can’t. The avoid obstacles mode also works but once again is totally limited by
this robot model’s lack of any ability to turn.
It is truly weird in the way that it walks. The biggest limitation of this six-legged robot (and to some
extent the other versions too) is the surface on which it walks. The ‘Beetle’ has difficulty turning on
carpets and has no traction at all
on slippery tiled surfaces.
Starting with a completely built (fully assembled) mBot, remove the two drive wheels and put them on
one side together with the two little self-tapping screws that hold them on to the axles of each electric
motor (but leave the tyres on the wheels this time).
Add two 7mm dia. x 3mm thick Plastic Spacers to the Screw on the
outside of the wheel and then add a single 11-hole, 108mm 0412
Beam to the assembly using the end hole in the Beam securing it in
the usual way with an M4 Lock-Nut.as shown on the left.
Attach a 10-hole, 92mm 0412 Beam to the end of the 11-hole, 108mm
0412 Beam to extend it as shown in the diagram below using two
You can also see that I used my own M4 wing nuts for speed in assembling / disassembling the
modification.
The ‘Crazy Frog’ model works best at top speed (Button 9 on the IR remote). I suspect that you won’t
write a control script in mBlock for this - we never did!
The mBot Interactive Light & Sound pack is yet another add-on 3-models-in-1 pack for mBot. The
MakeBlock advertising blurb for this says that you can construct either a ‘Light Chasing Robot’, a
‘Scorpion Robot’ or an ‘Intelligent Voice-Activated Desk Light’.
The ‘Light-Chasing Robot’ model detects the light intensity around mBot using the two light sensors,
one mounted on each side of the model. When the light intensity on the left side is greater than that on
the right the robot will turn left; when the light intensity on the right side is greater than that on the left
side, the robot will turn right; otherwise, the robot will go straight. With minimal changes to the basic
model, this modification still allows the full use of the default IR functions built into mBots firmware.
The ‘Scorpion Robot’ model gives mBot a scorpion-like curved tail and by adding this to the rear of
mBot it alters the centre of gravity, making it easier for mBot to raise its head and do a “wheelie” when
it powers forwards.
By totally changing its building configuration, mBot can also be turned into an ‘Intelligent Desk Light’
with two operating modes. Touch-mode, where the brightness of the light can be regulated by touching
the line following sensor with your fingers, and voice-activated mode where the sound level in the area
surrounding the desk light is polled and if the volume increases significantly, the light is turned on.
The advertising material also says that each model has infinite possibilities for experiencing with mBot
the magic of light and sound. Information in this pack is, however, minimal (see below) - nevertheless
if you buy it via China, it only costs approx. £20 inc. free postage - once again an absolute bargain, and
mine arrived trouble free in seven days.
The little manual that comes with the pack (as in the servo pack) shows a sequence of graphics (once
again in a similar style to the original mBot manual) showing how to modify mBot to create all three
models. It also describes (very briefly) each of the Me Modules contained in the pack.
Thanks to previously searching for the elusive Servo Pack Instructions I knew that I could return to the
Makeblock page describing add-on packs (see pages 196 and 197). Here I found the complete model
making instructions and some programming examples using the following link:
http://learn.makeblock.com/en/mbot-add-on-packs/
As I had found earlier, the programming files were stored as RAR files, so once again I used 7-Zip to
decompress them. On examining these mBlock files, I was delighted to see that everything was in
English including the comment callouts attached to some script blocks. Written in English, but as usual
needing some work to clarify the meaning!
Once again, buying an add-on pack like this will give you a few more extra construction bits to add to
your collection. Increasing your collection will enable you to experiment with your own robot
constructions (see page 157 to see the collection that I have amassed from add-on packs).
8 × M4 x 22 Screws
15 × M4 x 14 Screws
8 × M4 x 8 Screws
9 × M4 Nuts
9 × 3mm x 7mm dia. Plastic Spacers
The pack contains another little spanner (the same as the “wrench” supplied in the Servo Pack). There
are also two very useful 35cm lengths of Me cable with 6P6C RJ25 plugs at each end - a welcome
addition to your kit since the default lengths supplied with mBot are only 20cm long.
Finally, the included circuitry - The pack contains two Me Light Sensor V1 Modules - these are based
on the principle of a semiconductor’s photoelectric effect. They can be used to detect and differentiate
between the light intensity in a surrounding area or determine light variances on different coloured
surfaces. These sensors can be used to make mBot projects (such as the light chasing robot and the
dimming desk light) interact with light.
There is also one very useful Me Sound Sensor V1 Module which can be used to detect the sound
intensity in a local area by measuring volume. This is a sensor which gives mBot a “listening” capacity
by utilising a microphone and a low-power amplifier combination. This sensor can be used to make
interactive mBot projects like a voice operated switch, a voice-activated light or to get mBot dancing in
time to musical rhythms.
Finally, there is one Me RGB-LED V1.1 module (exactly the same 4-LED module as supplied in the
Servo Pack) so you now have two of these too.
On the whole, another very good value pack of bits and pieces (the above Modules alone would cost in
the region of £20 to buy as individual items).
A Light-Emitting Diode (a LED) is a semiconductor light source. RGB LEDs consist of one red, one
green and one blue LED and by independently adjusting each of the three they can produce a wide range
of colours. LEDs are energy efficient and their disposal causes few environmental concerns. LEDs also
have a long lifespan and are subject to very limited wear and tear if operated at low currents and at low
temperatures.
Red, green, and blue colours can be combined (as described on the previous page) by using specific
programming blocks in mBlock 5 to produce both white and coloured light from any Makeblock LEDs.
mBots own main mCore board has two 5x5mm full-colour ws2812 RGB LEDs. Each of these LEDs has
an integrated chip that enables you to control its colour individually by adjusting its brightness value and
thereby creating any colour that you want by mixing different amounts of red, green and blue light.
Each pixel of the three primary RGB colours can achieve up to 256 levels of brightness and when these
are mixed have the potential to display 16,777,216 true colour display combinations!
The second button in mBot’s ‘Blocks’ categories list accesses the ‘Show’ blocks. Three out of the five
‘stack’ blocks in this category offer slightly different ways of ways of programming the LED lights on
the mCore board. Shown on the left is one
of those ‘stack’ blocks. This block allows
you to choose either the left LED or the
right LED or both LEDs (all) and set the individual RGB values for them.
There are two other sets of programming blocks which allow you to control LED lights, but for these
you need to load in an ‘extension’ set of blocks. If you load in the ‘Light Sound’ extension, then it gives
you three ‘stack’ blocks rather similar to those described above, but this time they are for controlling
add-on Me Modules
connected to ports on mBot.
Each of the ‘stack’ blocks described on the previous page requires an RGB value (in a range from 0 to
255) to be entered into each of the little windows next to ‘red’, ‘green’ or ‘blue’ in each block.
N.B. mBlock 5 blocks that set RGB values for LEDs do not accept decimals as a brightness value - only
integers are acceptable.
The LED lights targeted by your choice of block will mix red, green and blue light in the specified ratio
to achieve almost any colour combination. These red, green and blue values are in LED terms the
brightness value of each of these colours - the bigger the value, the brighter and more dazzling the
colour! If all the RGB values in the block are set to zero then the targeted LED will show no colour i.e.
it has been turned ‘Off’! - Do note too, that mixed colours seem brighter than any single colour.
It is also worth noting that when setting LED colour combinations colours can be more clearly
identified if they have lower brightness settings; and it is sensible (if you want to prevent dazzling) to
set each LED to a value below 40. This will enable clear identification of both colour and light levels.
However at times, you may want to ignore this advice and just dazzle!
To set appropriate colour and light values for Makeblock LEDs you can refer to an RGB colour table
(from the internet or perhaps from the colour palettes available in Microsoft applications). I took this a
little further and experimented with RGB colour mixes using an Excel spreadsheet.
I divided each of the standard RGB colour table values (which I had found on the internet) by 6.375
(255/40) and then rounded the result to an integer
to determine a value to set the red, green & blue
values of mBlock’s programming blocks with a
non-dazzling value (integers <= 40).
I tested many of these RGB LED value colours in mBlock 5 by generating a new project file in which I
created three variables ‘R_LED’, ‘G_LED’ and ‘B_LED’. I enabled the display of these three variables
onto mBlock’s ‘Stage’, giving them slider controls (see the diagram on the right) which allowed them to
be quickly adjusted from 0 (min.) to 40
(max.). In then used these values to set
the LEDs on mBot to test the ‘look’ of
each colour.
In my colour-mixing Excel spreadsheet file I originally created a table for greyscale values, but these
LED colours didn’t really work in practice, so I deleted that part. It’s not really a true statement to say
that LED lights can depict any colour. The fifty-five shades of Red, Orange, Yellow, Green, Violet and
Blue that I have listed all do work, but I was rather disappointed with many of the darker shades
(especially browns) not really working; even if I proportionally reduced the RGB values even more to
make them duller. This is possibly because the closer you get to the upper range of output values;
everything becomes whiter and individual colours are harder to discern.
If you set all three RGB colours to full brightness you will get something close to white light, but if you
set all three of them to minimum (zero, zero, zero) or even fairly low levels of brightness, you’ll get no
visibly discernible output from mBot’s LEDs!
If the voltage to a LED is lowered, the brightness will go down; but lower the voltage enough, it will
simply turn off. It is clear therefore that mBot isn’t capable of truly dimming a LED, because a LED
can’t be dimmed effectively. To emulate the dimming of LEDs, Arduino boards (like mCore) use Pulse
Width Modulation (PWM) and the microcontroller that they use has several built-in PWMs which can
be used to adjust the brightness of a LED via programming; switching it on-and-off so quickly that you
don’t notice the flicker.
To make a LED look like it’s set to 10% (26/255) brightness, an Arduino board (using PWM) will keep
it ON for 10% of the time and OFF for 90% of the time that the LED is activated. In your own coding
using mBlock 5, in reality you don’t have to worry about what is happening here; so just ignore PWM
and send a range of voltage values (from 0 to 255) that correspond to the brightness levels that you
require.
Footnote: Despite all of the above, personally I am not overwhelmed by the output from RGB LED
lights at all. They are OK and they do have their place in projects (and are much better too if seen in
the dark) but they are nowhere as exciting or ‘cool’ as they are made out to be!
I created the script shown below-right to test that LEDs could be dimmed using a script:
I also created the following script to set the two LEDs on mBot and the four individual LEDs on an Me
RGB-LED module to produce random colours and repeat them forever as quickly as possible in a non-
stop display of ever-changing light patterns:
I needed something very similar to this script (merged with one of my ‘Head-Shaking Cat’ routines) to
programme the ‘Light-Emitting Cat’ (see ‘Appendix 5 on page 215).
N.B. Sadly, all that I had to go on as guidance for that project was the IMPOSSIBLE claim in the
promotional blurb for the Makeblock Servo add-on pack which described the ‘Light-Emitting Cat’ as
follows:
"A nice cat brightens up your life - The light pierces the darkness - It's brighter in the sun"
The build instructions for the model show the RGB-LED module mounted on a servo (just like the Me
Ultrasonic Sensor module was mounted for the ‘Head-Shaking Cat’); but this time mounted on the rear
of mBot - like a cat’s tail perhaps - or somewhere where the sun does shine!
…Since I now had two RGB-LED modules, it gave me the idea of replacing the two light-
sensors on the front of the mBot model that I had just built with these two LED modules to
create a new model variant of the ‘Light Emitting Cat’; but using the configuration of the
‘Light-Chasing Robot’ model and totally dispensing with the boring servo ‘tail’ of the
original ‘cat’ model. To do this I simply made a copy of my original ‘Light Emitting Cat’
project file (see ‘Appendix 5 on page 215) and deleted the ‘Move_Tail’ function and added
four more lines to the ‘Flash_LEDs’ function to flash the LED module on port4 together
with the LED module on port3 (as well as the two onboard LEDs). This was a much more
satisfying model that showed mBots potential for producing ‘disco’ light displays.
… mBot’s mCore main-board has a fool-proof and sturdy RJ25 wiring system providing a simple
method of connecting all of Makeblock’s Me modules to it. These RJ25 sockets all have coloured
labels, but nowhere in mBots little construction booklet does it tell you what these colours mean, or their
significance. Once again I had to trawl the internet to find out that the RJ25 connection ports on either
side of mBot have different colour-coded combinations.
Makeblock’s concept is that any
compatible Me module must connect to a
controller-board port which has a coloured
label matching its own coloured label.
But nowhere is this made very clear! It is very easy to connect one of the black label light sensors
to the wrong type of port! I got this wrong the first time that I connected this sensor since black labels
are on these modules, but confusingly they do not show-up at all well on the black plastic tops of the
RJ25 ports! Sound reporter blocks also have a black label and also only report output via ports 3 or 4.
I should have realised that Makeblock knew best, but in my ignorance, I thought that I could leave the
line-following sensor connected to port2 and the ultrasonic-sensor connected to port3 (where they have
always been connected since mBots initial set-up). To me, this made considerable sense because that
left port1 free on the left of mBot and port4 free on the right of mBot; so connecting the matching light-
sensors on each side (left-to-left & right-to right) would be logically very straightforward.
• A Yellow label indicates a ‘One-Way Digital Interface’ which allows the connection of either an Me
Ultrasonic-Sensor module, an Me RGB-LED module or an Me-Limit Switch module.
• A Blue label indicates a ‘Dual Digital Interface’ which allows the connection of either an Me Line
Finder module, an Me 7 Segment LED Display module, an Me PIR Motion Sensor module, an Me
Camera Shutter module or an Me Infrared Receiver Decoder module.
• A White label indicates an ‘I ² C port’ which allows the connection of either an Me 3-Axis
Accelerometer module or an Me Gyro-Sensor module.
• A Black label indicates a ‘Dual & One-Way Analogue Interface’ which allows the connection of either
an Me Light Sensor module, an Me Sound Sensor module, an Me Potentiometer module, an Me
Joystick module, or an Me 4 Button module.
and additionally, on other Arduino boards (but not mCore):
• A Red label indicates an output voltage of 6-12v DC, which allows the connection of either an Me
Motor Driver, an Me Servo Driver or an Me Stepper Driver.
• A Grey label indicates a ‘Hardware Serial Port’ which allows the connection of either an Me
Bluetooth BLE module, or an Me Bluetooth (Dual Mode) module.
On the next page is the marginally modified and transcribed programme which I originally downloaded
from Makeblock (as an mBlock 3 file) to operate the ‘Light-Chasing Robot’.
I removed the ‘mBot Program’ hat block and replaced it with a ‘when (up arrow) key pressed’ hat block
intending to run the programme via a Bluetooth connection rather than (as it is in the original) being
uploading into Arduino for off-line use.
I made two Variables called ‘Light_Left’ and ‘Light_Right’ to store the feedback from each of the two
Me Light Sensor V1 Modules used in the project. I also created a self-defined ‘My Block’ which I
named ‘Sensor_Feedback’. In the main script routine, the single ‘Sensor_Feedback’ block is called
three times, which by being inside a forever loop gives constant feedback into the two variables shown
on the ‘Stage’. You will also note in the programme shown overleaf that I added a simple one-block
‘mBot_Stop’ script (using the ‘when (space) key pressed’ hat block to halt the robot when necessary.
Remember to connect mBot to mBlock5 using the Bluetooth connection. To operate the model, press
the up arrow on the keyboard to start mBot - or hit the spacebar to stop mBot. Use a torch to control
mBot’s movements by letting it follow (or ‘chase’) the torch-light. When the light-intensity on the left
is greater than on the right then mBot will turn left. When the light-intensity on the right is greater than
on the left then mBot will turn right. Otherwise mBot will continue to move forwards until stopped.
Shown below is the very simple ‘Light-Chasing Robot’ programme transcribed into mBlock 5 format
from the original mBlock 3 file downloaded from Makeblock:
N.B. You could try other power settings here, but 35% and 70% seem to work very well for this model.
The model shown below (& it’s so different to usual!) is what you are going to create next.
The ‘Intelligent Desk Light’ mBot modification requires a complete disassembly of mBot and a
completely new configuration to be built (see the diagrams above and the illustration below-right).
Next attach to the vertical 0824 Beam the Me Line-Follower Sensor using two M4 x 14 Screws and M4
Nuts (as shown in the diagram above) - do note from the diagram the correct mounting attitude of the
module, the holes used and the direction of the RJ25 port.
Also attach to the vertical 0824 Beam, a 5-hole 72mm 0808 Beam as shown at the top of the diagram
above. Note that an M4 x 22 Screw and M4 Nut are used through the bottom hole of the 0808 Beam and
that an M4 x 14 Screw is used through the next hole which is screwed into the slot the vertical 0824
Beam (so no M4 Nut is necessary here).
However …
…When I started disassembling mBot, by removing the mCore board and the Line-Follower sensor,
I thought it made considerable sense to leave in place the rest of the components fitted to the
chassis ready for instant mBot reassembly. The chassis being used as a ‘shade’ for the desk light is
OK, but not really necessary if you use a bit of lateral thinking and improvisation - a shade is just a
simple hollow shape - a box!
So off I went to our household recycling bin to see what I could find. I had it in mind to use a margarine
tub - (not far off in size I thought from the dimensions of mBot’s chassis; lightweight & structurally
strong too). Sadly, there was none to be found, but I did find
a sturdy aluminium foil tray (200 x 120 x 40) that looked fit
for purpose. It had contained Moussaka - I think !?!
The idea was to stiffen the wall of the tray on the inside
using the angle bracket; and as a stiffener on the outside
I made a little wooden spacer (tapered to match the
slope of the tray). I used two long M4 screws passing
through all of these and through the supporting arm to
pull the whole of this assembly tight - it worked very
well (see the photograph on the right):
Shown below are two views of the complete assembly of my modified variant of the ‘Desk Light’
model.
Do note from the left-hand picture that if you have a Li-Po battery similar to the one that I specified on
page 33 it does tuck away neatly underneath the mCore board - there is also room for the two cables
from the two RGB-LED lights to pass below the model too.
I connected the two Me RGB-LEDs of my model to ports 1 and 2 on mCore (at the front of the model),
the Me Line-Follower Sensor was connected to port3 and the Me Sound Sensor was connected to port4
(at the back).
Next I modified the Makeblock script for controlling the desk-light model (see the next page) which I
had downloaded by changing all references to ‘port3’ in all of the ‘set LED’ stack blocks (there were
eight of these) to ‘port1’. I then went back to each of these eight stack blocks in turn and duplicated
each one, adding the duplicate immediately below the original and setting the duplicate block each time
to read ‘port2’ instead of ‘port1’. This was so that the script sequence could control my two Me RGB-
LEDs using ports 1 and 2. I also changed the three ‘line follower’ Reporter block references to ‘port3’
(leaving the one reference to the sound sensor remaining as being connected to ‘port4’).
The downloaded script has five Variables: ‘Red’, ‘Green’, ‘Blue’, ‘mode’ and ‘lightIntensity’. I could
not see any use for the ‘Red’, ‘Green’ & ‘Blue’ Variables anywhere in the script; so I deleted them (and
the script continued to function as it did before). The second modification that I made was rather
pedantic, but I wanted to follow the naming convention that I have used throughout the pages of this
book.
I renamed ‘mode’ to ‘Mode_Value’ and ‘lightIntensity’ to ‘Light_Intensity’. I also modified the monitor
readout for the ‘Light_Intensity’ Variable on mBlock’s ‘Stage’ by giving it a slider to control the
brightness of the light if thought necessary.
The ‘Light_Adjustment_Factor’ that I created needs to have a value set at project start-up to provide the
step value that the ‘Touch’ light needs to increase or decrease brightness. I intend to set this to a step-
unit of 5; but it is very easy to alter this in a ‘set (variable) to’ block.
The ‘Light_Duration_Factor’ that I created also needs to have a value set at project start-up to provide
the period of time for which the ‘Sound’ light would remain on. I intended to set this to a very short test
value of 2 seconds - but it is very easy to alter this in a ‘set (variable) to’ block too.
The ‘Light_Intensity’ variable was renamed from the ‘lightIntensity’ variable of the original script. This
is used to contain a value (0 - 255) which is the brightness of the light. I also set its monitor readout
window on the ‘Stage’ have a slider so that I could manually adjust the brightness of the light.
The ‘Mode_Text’ variable I added to provide some text feedback to the ‘Stage’ showing the current
mode of operation.
The ‘Mode_Value’ variable was renamed from the ‘mode’ variable of the original script. This was
designed to contain a value (0 or 1), to act as a switch to change the light operating modes. I intended to
use this again (after my a ‘repeat until’ loop experiments) to switch scripts, but this time using (1 or 2).
I created the Variable ‘Sensor_Value’ to receive feedback from the ‘line follower’ Reporter block
(connected to port3). This sensor returns a value of 0, 1, 2, or 3 representing four different levels of
reflected light and a ’Stage’ display of this variable will be extremely useful when testing the sensor.
Shown above (and on the previous page) are most of the scripts that make up my modified and reworked
solution to the ‘Intelligent Desk Light’ project. At the top of the next page are the remaining two scripts
which set the LEDs. At this stage of your progress through this book you should find that these scripts
are all clearly understandable.
Clicking the ‘green flag’ activates the project and sets up the values required for several of the
Variables. You can change the step value for light intensity changes here as well as the time the light
remains on before it automatically turns off in ‘Sound’ mode.
The left and right cursor keys on the keyboard switch modes and the spacebar turns off the desk-light
and stops everything.
Makeblock’s interpretation of the ‘Intelligent Desk Light’ makes a very clever and well thought-out use
of the line-following sensor by using its two pairs of infrared LEDs to provide ‘touch control’ to adjust
the desk-light’s brightness. See Chapter 12, page 64 for more on how the line-follower sensor works.
N.B. There are a pair of small blue indicator lights on the top of the line-follower module and each
blue light is a good indicator of what each of the two LED pair components can ‘see’ and they indicate
the following:
• If both are OFF this indicates low levels of reflected light and the sensor module reports the value
’0’.
• If the bottom blue light is OFF, it shows that low reflected light (a black surface) is detected on the
bottom pair of LEDs and the module will report the value ‘1’.
• If the top blue light is OFF, it shows that low reflected light is detected on the top pair of LEDs and
the module will report the value ‘2’.
• If both blue lights are ON, they indicate that there are high levels of reflected light and the sensor
module reports the value ‘3’.
My project solution only uses the returned values of 1 and 2 to determine whether the desk-light’s
brightness should be increased or dimmed. The original project used the value 3 to make the light flash
red, green and blue but since it was easy to activate this by mistake I removed this option altogether and
replaced it with the randomly chosen values created in my self-defined ‘Light_Soft_Colour_Mix’ block
which is activated by pressing the zero (0) key on the keyboard.
Should there be a graphical ‘front-end’ for this project using ‘Sprites’ tab scripting?
I decided that one was not really needed here - but you can do this using the principles that you have
learned earlier if you want to!
Thanks to this
modification I found
that the original sound
sensor threshold setting
(550) was too high for
the script to work but
setting it to 250 worked
fine.
Hyped by the
advertising blurb,
Emma and I both had
high hopes and great
expectations for this
apparently exciting
project. Much on a par
with the ‘Walker’ robot
models discussed
earlier, this very sadly
was rather a boring
model to both construct
and to programme.
Emma thought the project was OK - but I was very disappointed with the overall outcome!
Several suppliers of Makeblock robotics kits and components in Europe have come and gone in the
eighteen months that I have been experimenting with mBot and writing this book. As I have mentioned
earlier, many component kits and individual component parts are hard to come by in the UK - unless
bought online with quite excessive shipping charges.
It has therefore been good to see that this year Makeblock have set up a UK storefront in the Amazon-
EU Online Store (although all products purchased there still ship from Germany with a fairly hefty £5
shipping charge applied on top of fairly premium prices) - so, costly, but easy to do and safe!
The add-on-packs already addressed in these appendices are however still easily obtainable in the UK at
a reasonable cost, but I am unlikely to buy any more even though three new add-on packs for mBot seem
to have appeared over the last year.
• I have been almost tempted by the ‘Talkative Pet’ pack, but at £43 it’s no thank-you! (although it’s
almost worth it since it contains the hard-to-get Me Audio-Player module).
• The ‘Variety Gizmos’ add-on pack at £37 would give me the rather desirable Me 7 Segment Display
module and two (v. B) Micro Switches but out of the six models described for construction three are
the same ‘Cat’ models that can be made with my existing ‘Servo’ pack.
• The ‘Perception Gizmos’ add-on pack at £46 would give me an 8×16 LED Matrix Display panel and
a Sound Sensor, both of which I already have from my earlier purchases; but I would gain a
Temperature and Humidity Sensor, a Potentiometer and a little Motor Pack - sadly, one of the five
models that is suggested is the ‘Intelligent Desk Light’ (from my existing ‘Light and Sound’ pack).
Rather than spending more on these packs, I would much rather spend £125 on Makeblock’s
‘Electronics Inventor Kit’. This does have twelve mBot (and mBlock 5) compatible plug-and-play
sensors and actuators although it is not an mBot add-on. This kit contains a very useful ‘Orion’ main
control board that I could programme instead of mBots mCore and this would, I guess, tempt me into
moving from mBlock 5 into Arduino programming.
If I chose to spend even more then I would probably upgrade from mBot altogether and go for
Makeblock’s ten-in-one ‘Ultimate Robot v.2.0 Kit’ at £280 - (& Emma gets to keep her mBot!).
Makeblock
designed to have a WoW! Factor”.
mBot
Robotic
Device
“So
… think Laterally
… be Innovative
… Experiment
… Practise
… Plan Ahead
and develop
Good Computer Habits”.
Bye-Bye
Index
A chassis: 1, 8, 33, 61, 62, 64, 158, 159, 172, 174,
177, 178, 179, 181, 182, 183, 184, 207,
A.I.: 12, 50, 137 216, 222, 223, 224, 225, 228, 229, 230,
Action: 44, 45, 48, 57, 102 231, 244, 246, 247, 255, 256
Activated: 19, 24, 36, 38, 39, 48, 51, 60, 63, 76, 79, Climate Data: 50, 51, 137, 138, 140
80, 104, 107, 120, 121, 128, 148, 165, Clone Stamp: 84, 94
166, 191, 198, 209, 214, 232, 233, 238, Cloud: 12, 14, 15, 16, 17, 50, 87, 104, 152, 153
244, 253 Code: 4, 7, 11, 12, 14, 15, 18, 19, 30, 31, 32,
add-on packs: 3, 8, 10, 30, 48, 61, 171, 196, 197, 220, 35, 37, 40, 41, 51, 53, 54, 56, 65, 80, 87,
232, 244, 256 151, 152, 153
algorithm: 38, 41, 52, 62, 82, 159, 161, 204, 212 Codey Rocket: 11, 17, 20, 44, 102, 153, 154
alphanumeric: 13, 42, 43, 70, 77, 79, 87, 90, 98, 138, COM: 23, 26
142 Command: 5, 9, 10, 13, 30, 31, 36, 39, 52, 59, 67,
ambient light: 60, 65, 66, 163 77, 81, 98, 102, 172, 221
analogue: 13, 31, 61, 77, 79, 98, 100, 103, 106, Comment: 35, 87, 151, 153, 196, 197, 198, 220,
107, 116, 117, 135, 161 226, 232
animation: 6, 30, 70, 72, 95, 186, 189 Connect: 19, 20, 22, 23, 24, 25, 26, 27, 69, 107,
App: 3, 5, 11, 20, 23, 29, 30, 31, 32, 80, 82, 111, 124, 201
83, 94, 152, 153, 155 Connection: 2, 20, 22, 23, 24, 25, 26, 27, 28, 29, 33,
Arduino: 1, 4, 5, 7, 10, 11, 12, 14, 18, 19, 25, 33, 48, 174, 207, 225, 241, 242
35, 43, 102, 151, 198, 238, 242, 246 Construction: 1, 2, 3, 4, 71, 91, 92, 143, 177, 181, 192,
Artwork: 80, 82 193, 199, 216, 219, 220, 222, 225, 226,
axles: 158, 178, 179, 227, 230 230, 231, 232, 240, 241, 254
control: 4, 5, 9, 13, 19, 22, 24, 27, 28, 29, 30, 31,
B 35, 36, 37, 39, 44, 45, 46, 47, 48, 49, 52,
53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 77,
Backdrop: 6, 19, 21, 35, 70, 72, 80, 82, 83, 85, 86, 79, 80, 81, 82, 88, 98, 102, 103, 105,
87, 88, 89, 90, 94, 100, 103, 131, 132, 112, 125, 157, 193, 196, 197, 210, 212,
133, 134, 135, 139, 146, 154, 161, 198 214, 221, 226, 230, 231, 234, 235, 242,
Backup: 16, 79, 87, 104, 116, 117, 118, 122, 123, 248, 249, 253
124, 127, 129, 131, 133, 134, 135, 151, costume: 19, 53, 70, 72, 75, 82, 83, 86, 90, 95, 90,
153 100, 107, 112, 113, 114, 116, 117, 118,
Batteries: 5, 33, 34 126, 127, 129, 130, 131, 132, 133, 134,
Blockly: 30, 32, 52, 80 135, 142, 144, 145, 146, 147, 164, 169
Blocks: 18, 20, 35, 37, 40, 41, 44, 45, 47, 52, 64, Costume Editor: 70, 82, 83, 90, 100, 107, 112, 113, 127,
65, 72, 102, 107, 109, 115, 120, 122, 131, 132, 133, 134, 135
129, 142, 143, 151, 209, 213, 218, 235, crank: 171, 172, 173, 175, 176, 178, 179, 180,
249, 251 182, 183, 222, 226, 227, 229
Blocks Area: 15, 28 Create: 31
Bluetooth: 2, 5, 9, 22, 25, 26, 27, 29, 30, 33, 48, 54, Cursor Keys: 57, 92, 152, 209, 210, 213, 214, 253
61, 242
Boolean: 36, 40, 42, 46, 47, 49, 59, 63, 149 D
brass pillars: 172, 177, 179, 180, 199
broadcast: 13, 42, 43, 47, 50, 74, 75, 76, 77, 79, Data: 14, 43, 47, 50, 60, 61, 86, 101, 105, 116,
101, 102, 103, 105, 106, 109, 112, 116, 144, 145, 164
118, 121, 123, 126, 127, 129, 131, 139, data-on-demand: 13, 42, 77, 81, 98
140, 145, 146, 148, 151, 166, 169, 188 default: 3, 7, 9, 13, 14, 15, 16, 18, 20, 21, 23, 24,
Broadcast Messages: 76, 77, 79, 81, 98 28, 29, 30, 40, 44, 47, 48, 52, 59, 61, 62,
Bubble: 55, 56 70, 84, 85, 86, 88, 89, 101, 102, 104,
Buzzer: 9, 10, 27, 29, 45, 54, 55, 209 105, 106, 128, 144, 148, 149, 150, 152,
153, 154, 155, 232, 233, 246, 249
C Delete: 35, 51, 71, 104, 123, 126, 129
Design: 31, 80
cable: 1, 8, 10, 27, 156, 174, 193, 194, 248 Device: 13, 14, 17, 19, 20, 22, 23, 25, 26, 42, 44,
cam: 50, 149, 222, 227 47, 50, 77, 81, 98, 153, 154
Device Library: 14, 20, 153
Device Manager: 23, 26 folder: 16, 87, 94, 152, 153, 154, 155, 197
Devices: 12, 13, 14, 18, 19, 20, 22, 44, 47, 48, 49, forever: 37, 39, 59, 60, 63, 65, 66, 128, 129, 187,
52, 54, 57, 58, 59, 62, 65, 66, 67, 69, 74, 191, 210, 213, 239, 242, 250
75, 76, 79, 81, 102, 103, 106, 108, 111, Forum: 6, 9, 25, 196
112, 116, 153, 154, 160, 165, 185, 188, Freeform Shape: 71, 73, 91, 92, 164
205, 250 frequency: 55, 56, 62, 171, 234
Dialogue: 16, 23, 24, 25, 26, 143, 152 front wheel: 158, 159, 222
dice: 67, 68, 69, 70, 71, 72, 73, 75, 76 Full-Screen: 13, 18, 85, 106, 119
different tabs different script: 13, 44, 77, 81, 98
digital: 9, 13, 47, 61, 67, 77, 79, 87, 90, 98, 100, G
104, 112, 117, 118, 122, 129, 131
display: 9, 10, 13, 18, 19, 31, 36, 39, 44, 47, 50, GitBook: 27, 78
60, 65, 66, 67, 70, 74, 76, 77, 80, 81, 82, GitHub: 11, 77
85, 86, 88, 90, 91, 92, 94, 98, 100, 106, Global: 25, 40
107, 113, 116, 118, 126, 127, 128, 129, gradient: 94, 95, 164
131, 133, 134, 137, 145, 146, 148, 161, graphic: 9, 13, 19, 20, 21, 37, 42, 44, 70, 72, 73,
167, 169, 184, 185, 186, 187, 188, 189, 75, 76, 77, 79, 81, 82, 83, 84, 85, 86, 87,
190, 234, 235, 238, 239, 249, 251, 257 88, 89, 90, 91, 93, 94, 95, 96, 98, 100,
Dongle: 26, 27 102, 103, 104, 106, 107, 108, 109, 112,
Driver: 3, 23, 25 113, 114, 116, 117, 118, 119, 127, 128,
duplicate: 53, 114, 126 130, 131, 135, 139, 145, 146, 147, 151,
duplicating: 53, 70, 90, 91 160, 161, 163, 164, 165, 166, 167, 169,
171, 172, 184, 186, 190, 191, 192, 198,
E 220, 232, 236
Graphics Editor: 84, 90
Edit: 13, 15, 16, 17, 20, 57, 73, 85, 93, 106, Green Flag: 18, 35, 46, 53, 54, 59, 63, 66, 76, 103,
112, 113, 119, 132 128, 139, 146, 148, 151, 172, 191, 249,
editor: 7, 12, 14, 18, 21, 72, 77, 82, 83, 84, 90, 253
93, 106, 107, 112, 113, 127, 132, 133,
134, 135, 139, 146, 154 H
Events: 46, 57, 74, 101, 102, 103, 116, 212
Excel: 6, 68, 71, 95, 96, 236, 238 habit: 24, 35, 37, 38, 43, 76, 87, 151, 154
experiment: 54, 66, 153, 160, 219, 251 Harmonograph: 171
Export: 13, 87 Hat: 35, 36, 38, 53, 63, 66, 190
Extension: 9, 14, 44, 47, 48, 49, 50, 51, 55, 57, 58, high-quality: 6, 8, 13, 77, 79, 87, 89, 95, 98, 151
81, 102, 137, 140, 144, 149, 152, 153,
154, 155, 235
Extensions Centre: 47, 50, 51
I
if / then: 40, 59, 62, 63, 114
F if / then / else: 40, 59, 62, 63
Infra-Red: 59, 60
Factory Firmware: 24 Input: 28, 35, 38, 51, 54, 55, 56, 58, 60, 61, 79,
Factory Setting: 9 87, 100, 146, 152, 190, 250
feedback: 3, 9, 13, 17, 18, 31, 37, 39, 46, 47, 49, interface: 1, 2, 5, 6, 13, 15, 16, 17, 18, 19, 20, 22,
50, 51, 54, 56, 60, 61, 65, 66, 67, 70, 76, 26, 28, 29, 30, 31, 32, 35, 61, 77, 79, 80,
77, 80, 81, 82, 86, 87, 88, 90, 98, 100, 82, 85, 87, 89, 98, 100, 103, 104, 107,
106, 107, 108, 112, 116, 117, 122, 137, 111, 112, 116, 117, 118, 119, 120, 127,
140, 147, 148, 160, 161, 164, 166, 167, 128, 129, 130, 131, 133, 134, 135, 151,
184, 186, 187, 188, 189, 209, 210, 212, 193
213, 240, 242, 251, 257 IR control: 9, 28, 29
files: 13, 15, 16, 17, 20, 21, 22, 43, 48, 52, 55, IR remote: 3, 5, 9, 10, 28, 29, 30, 33, 53, 54, 59, 60,
71, 82, 83, 84, 85, 87, 89, 93, 94, 95, 63, 156, 221, 226, 229, 230, 231
131, 151, 152, 153, 154, 155, 190, 196, Isometric: 71
197, 198, 220, 232
firmware: 7, 9, 19, 20, 23, 24, 25, 232
flash memory: 7, 10, 22, 25, 37, 54, 59, 81, 217, 241,
K
249, 250, 253
key-presses: 79, 183
panel: 9, 10, 15, 18, 19, 20, 21, 22, 24, 25, 31, RGB: 29, 48, 61, 93, 193, 215, 216, 217, 218,
44, 47, 49, 51, 67, 88, 106, 107, 112, 219, 233, 234, 235, 236, 238, 239, 241,
154, 184, 186, 187, 189, 190 242, 246, 247, 248, 254, 255
Pantograph: 171 RJ25: 8, 61, 193, 194, 195, 199, 201, 206, 207,
parallel: 76, 196 216, 217, 219, 233, 241, 245, 246, 254
P.C.: 2, 7, 9, 22, 23, 24, 25, 26, 27, 37, 51, Robot: 1, 3, 4, 7, 8, 9, 10, 17, 20, 25, 32, 35, 44,
152, 153, 154 48, 53, 57, 81, 155, 156, 158, 159, 172,
Pen: 51, 146, 147, 161, 167, 171, 172, 174, 184, 192, 193, 199, 220, 221, 226, 232,
176, 178, 179, 180, 181, 182, 183 233, 242, 256
Photoshop: 84, 89, 93, 94, 164 Robotics: 3, 4, 5, 6, 9, 10, 11, 12, 14, 17, 19, 20,
pixel: 88, 89, 185, 235 23, 29, 35, 44, 46, 47, 50, 57, 67, 76, 77,
Plastic Rivets: 182, 221 79, 80, 81, 82, 88, 152, 153, 155, 157,
play note: 55, 56 159, 160, 185, 250
pointer: 84, 100, 103, 106, 107, 108, 116, 117, Rock, Paper, Scissors: 43, 70, 73, 74, 137, 146
120, 123, 132, 135 roulette: 172, 176, 180
port: 2, 23, 24, 25, 26, 27, 33, 34, 125, 164,
201, 207, 241, 242, 245, 246 S
power: 3, 7, 9, 23, 26, 27, 28, 33, 34, 45, 57, 80,
102, 107, 112, 118, 120, 125, 128, 135, Save: 6, 17, 21, 37, 41, 54, 104, 151, 153, 155
137, 164, 174, 193, 201, 230, 233, 243 say: 67, 70
PowerPoint: 6 Scratch: 1, 2, 4, 5, 6, 7, 11, 12, 13, 14, 15, 18, 19,
Presentation Mode: 13, 85, 86 20, 32, 35, 36, 37, 44, 46, 47, 57, 70, 76,
problem: 3, 5, 6, 9, 12, 21, 23, 26, 27, 33, 34, 38, 77, 79, 80, 81, 82, 85, 86, 87, 88, 90, 98,
63, 81, 106, 108, 119, 121, 137, 153, 101, 103, 121, 137, 139, 140, 142, 172,
163, 174, 182, 197, 212, 230, 249 221, 249
processor: 1, 60 screen-grabbed: 84, 86
project: 8, 13, 14, 15, 16, 17, 21, 22, 32, 35, 42, Script: 13, 15, 18, 19, 20, 22, 25, 35, 36, 37, 38,
43, 48, 51, 52, 53, 57, 63, 67, 69, 72, 73, 39, 41, 42, 43, 44, 46, 51, 52, 53, 54, 56,
74, 75, 76, 79, 82, 83, 85, 86, 87, 89, 95, 57, 58, 59, 60, 62, 63, 65, 66, 67, 68, 69,
96, 98, 100, 101, 102, 103, 104, 105, 72, 73, 74, 75, 76, 77, 79, 82, 85, 95,
106, 107, 108, 109, 112, 114, 116, 117, 102, 105, 106, 107, 109, 112, 113, 114,
118, 122, 123, 124, 127, 128, 129, 131, 115, 116, 117, 118, 120, 121, 122, 123,
133, 134, 135, 136, 137, 138, 139, 140, 124, 125, 126, 127, 128, 129, 130, 131,
144, 145, 146, 147, 148, 149, 151, 152, 132, 133, 134, 135, 139, 140, 141, 142,
153, 155, 157, 158, 159, 160, 161, 163, 143, 144, 145, 146, 147, 148, 149, 150,
164, 167, 169, 170, 172, 174, 190, 197, 151, 152, 163, 164, 167, 169, 170, 185,
201, 204, 207, 210, 212, 214, 215, 217, 186, 187, 188, 189, 190, 191, 195, 197,
218, 219, 226, 238, 239, 241, 242, 249, 198, 204, 207, 209, 210, 213, 214, 217,
250, 251, 253, 254, 257 218, 230, 231, 232, 238, 239, 242, 246,
Python: 7, 12, 14, 18, 19, 32, 151 248, 249, 250, 251, 257
scroll: 9, 55, 109, 116, 186, 187, 189
R self-defined block: 43, 65, 120, 122, 123, 124, 143, 144,
148, 149, 150, 151, 167, 169, 198, 209,
Random: 67, 68, 69, 70, 71, 72, 75, 137, 147, 190, 210, 213, 217, 218, 251
213, 218, 239 sensing: 44, 45, 46, 51, 63, 107, 108, 128, 137
realism: 82, 106 Sensor: 9, 13, 18, 39, 47, 60, 61, 62, 64, 65, 66,
real-time: 13, 37, 39, 50, 60, 65, 66, 79, 80, 98, 69, 70, 75, 77, 81, 85, 86, 87, 88, 90, 98,
105, 117, 188 100, 104, 105, 106, 107, 108, 112, 116,
Recognition Window: 50, 149 117, 118, 122, 126, 135, 157, 158, 159,
reflected: 61, 64, 247, 251, 253 160, 161, 163, 166, 167, 189, 191, 199,
Repeat: 39, 40 206, 207, 209, 210, 212, 213, 221, 226,
Repeat Until: 40 230, 232, 233, 240, 241, 242, 244, 246,
Reporter: 18, 36, 39, 40, 41, 46, 47, 58, 62, 68, 69, 247, 248, 251, 253, 256, 257
119, 123, 128, 131, 137, 140, 147, 189, Serial: 3, 22, 23, 25, 26, 27
241, 248, 251 service bay: 155
Reset Default Program: 28, 37
Servo: 10, 47, 61, 157, 192, 193, 194, 195, 196, user: 6, 11, 12, 13, 15, 31, 35, 37, 39, 40, 41,
197, 200, 201, 203, 204, 206, 207, 216, 77, 79, 85, 154, 186, 190
220, 232, 233, 235, 239, 242, 247, 256
set-up: 21, 139, 153, 154, 164 User Guide: 11
Show: 18, 28, 44, 49, 108, 185, 186, 235 user-defined: 11, 37, 39, 40, 41, 190
Sign: 17, 22, 76
Software: 4, 5, 6, 7, 9, 11, 12, 13, 14, 15, 17, 22, V
23, 25, 26, 27, 30, 35, 50, 80, 81, 82, 86,
153, 188, 197, 198 Variable: 18, 37, 39, 40, 46, 47, 57, 58, 60, 62, 68,
Sounds: 19, 155 74, 101, 107, 129, 139, 187
Spirograph: 159, 171, 172 variable monitors: 67, 88, 89, 129
Sprite Library: 80, 82, 89, 90 variables: 38, 40, 42, 43, 50, 51, 58, 60, 62, 67, 68,
Sprite: 6, 12, 13, 14, 18, 19, 20, 42, 44, 47, 48, 69, 70, 74, 76, 79, 81, 86, 101, 113, 114,
50, 52, 67, 69, 70, 74, 75, 76, 77, 79, 81, 115, 128, 129, 131, 139, 140, 143, 146,
87, 89, 98, 102, 103, 104, 106, 107, 149, 172, 238, 239, 242, 251
117, 137, 153, 154, 155, 160, 165, 188, VBA (Visual Basic): 6, 95, 96
254 vector drawing: 84, 93
Stack block: 28, 35, 36, 37, 40, 41, 57, 63, 64, 67, 74, vectors: 83, 84, 90, 132
186, 187, 188, 189 version: 2, 5, 6, 7, 11, 15, 16, 17, 25, 27, 47, 55,
Stage: 6, 13, 15, 17, 18, 19, 20, 39, 68, 77, 79, 57, 69, 73, 85, 87, 95, 145, 146, 152,
103, 106, 187, 188, 198, 238, 242, 248, 160, 171, 172, 176, 177, 188, 190, 191,
251, 257 199, 207, 210, 212, 249, 250
Support Team: 26, 81 Video Sensing: 51, 137
T W
Tab: 67, 84, 163 wait: 60, 66, 75, 160, 163, 186, 188, 210, 218,
Teachable Machine: 50, 137 257
technical drawing: 71, 91 web-cam: 12, 50, 51, 137, 146, 147, 148, 149
technique: 28, 41, 79 wheels: 1, 53, 155, 157, 158, 171, 172, 173, 175,
Text-to-Speech: 51 179, 181, 182, 222, 223, 224, 227, 228,
think: 67, 70 229, 230, 231, 255
time clock: 128, 129 when key released: 46
Timer: 53, 139, 209, 210, 218 when this sprite clicked: 82, 116, 120, 121, 122, 123, 134,
Title: 16 135, 165
Training Model: 50, 149 While: 40
Translate: 51, 197 Wi-F: 5, 61
transparent: 83, 84, 93, 94, 95, 148, 164, 167, 219 Wondergraph: 171
trigonometry: 160 Word: 71, 73, 83, 84, 88, 89, 90, 91, 93, 107,
tutorial: 11, 16, 31, 32 117, 131, 139, 164
U Z
Ultrasonic Sensor: 8, 10, 39, 40, 60, 61, 62, 100, 105, 106, Zoom: 94
112, 117, 157, 159, 160, 161, 163, 170,
172, 184, 188, 189, 199, 200, 201, 206,
207, 209, 212, 213, 215, 217, 239, 255 File Types
underscore: 43, 151
understand: 3, 6, 8, 11, 12, 14, 19, 33, 39, 44, 52, 58, .gif: 84, 93
59, 60, 64, 69, 73, 75, 77, 81, 98, 112, .jpg: 83, 84, 89, 90, 93, 94
117, 121, 123, 151, 197, 208, 213, 249 .json: 87, 152
Update Firmware: 19, 23, 24 .mblock: 14, 152, 153, 207
Updates: 7, 9, 14, 17, 24, 25 .png: 13, 50, 71, 83, 84, 89, 93, 94, 95, 100,
112, 131, 138, 164
upload: 7, 13, 21, 22, 25, 37, 50, 54, 81, 82, 83, .rar: 197
87, 89, 95, 112, 131, 198, 242, 250 .sb2: 152, 153, 197, 207, 217
Upload Mode: 14, 18, 24, 47, 50, 77 .sb3: 14, 152
USB: 2, 22, 23, 24, 25, 26, 27, 33, 34, 61 .sprite3: 13, 82, 87, 151, 152, 155, 163, 169
He founded and ran the School’s dedicated C.A.D. classroom in 1991 and switched from teaching craft-based
skills to teaching Computer Studies / Information Technology in 1994. For the final fifteen years of his
teaching career he worked to establish ICT as a subject, teaching GCSE, A Level and the ECDL courses.
Lindsay’s interest, expertise and widely regarded innovative approach to ‘Creative Computing’ resulted in his
developing unique techniques to encourage pupils to explore the many possibilities offered by routine computer
software.
Deemed an expert in using the Microsoft Office suite of application packages, he was described as, “a teacher
who is very good at establishing the basics of good practice; an enthusiast who has developed unusual methods
of using application software… a true enthusiast who brought to his department specific expertise in graphic
design…”.
He retired from Oundle School in 2008, a senior master, where his role as C.O. of the CCF carried its own
Head-of-Department status. On his retirement from command in 2003, Her Majesty the Queen appointed
Lindsay as a Member of the Most Excellent Order of the British Empire in recognition of his exceptional
service as the Contingent Commander of the Combined Cadet Force at Oundle School.
The Naval Secretary’s announcement of this appointment in December 2003, stated: “Since joining the school
in 1976 you have made an outstanding contribution to the Combined Cadet Corps, first as Commanding Officer
of the Naval Section and, from 1988, as Commanding Officer of the entire Corps. Never flinching from your
duties, through hard work and dynamic and inspirational leadership you have had a tremendous and positive
impact upon the lives of many young people, gaining for Oundle School CCF a national reputation for the
quality of its service. Your tirelessness, enthusiasm and dedication have been remarkable and in the finest
traditions of the Service.”
His role in his final years at Oundle was that of School Proctor. He was a teacher for 38 years but estimates
over 40 years of continuous involvement with youth training.
He is married with one grown-up daughter and one grand-daughter and lists his hobbies as Sailing (he is a
member of the RNSA), Computing and Gardening. He was until recently churchwarden of his village church.