Micro:bit Quick Start Guide For Teachers
Micro:bit Quick Start Guide For Teachers
Wanna code?
• Step-by-step coding
W
challenges with clear
solutions
• Guidance on creating and
sharing your own programs
Supported by
Foreword
Computational thinking is the thought processes involved in formulating a
problem and expressing its solution(s) in a way that a computer – human
or machine – can carry out effectively. In 2006, I began to advocate that
everyone, regardless of profession, of career, or of age, can benefit from
learning how to think computationally[1]. With the BBC micro:bit, the BBC
and its partners, including Microsoft, catalyze our realization of this dream.
Children can learn how to think computationally by first formulating a problem
and conceptualizing a solution. Then, by expressing their solution using a
code editor, such as Microsoft Touch Develop, and by compiling and running
their program on the BBC micro:bit, they can see their code come alive!
I commend the BBC and the UK for their leadership in the Make It Digital
initiative. Teaching children at an early age the fundamentals of computing
helps provide them with the programming skills and the computational
thinking skills they will need to function in the 21st century workforce.
Programming the BBC micro:bit will teach children basic coding concepts,
such as variables, types, procedures, iteration, and conditionals. Solving
problems with the BBC micro:bit will expose children to computational
thinking skills, such as abstraction, decomposition, pattern matching,
algorithm design, and data representation. Students knowledgeable with
these skills will be in high demand by all industrial, government, and
academic sectors, not just information technology.
Most importantly, the BBC micro:bit will introduce children to the joy
of computing. Making one’s personal device do whatever one wants
is empowering. Programming the BBC micro:bit will tap into a child’s
imagination and creativity. The device and programming environment
provide a playful way to explore a multitude of computational behaviors.
I am thrilled to see this Quick Start Guide for Teachers, which is rich
with examples that show how hands-on coding is easy and natural.
Let’s have fun together!
Jeannette M. Wing
Corporate Vice President, Microsoft Research
25 May 2015
[1] Jeannette M. Wing, “Computational Thinking”, Communications of the ACM 49 (3): 33, 2006.
Contents
Lessons 12
Solutions 31
Acknowledgements
Written by: Miles Berry and Ray Chambers
Additional material written by: Ross Lowe
A catalogue record for this title is available from the British Library. This content is licensed under
ISBN: 978-1-471-86382-0 Attribution-NonCommercial-ShareAlike
CC BY-NC-SA
Printed in the UK by
Ashford Colour Press Ltd This licence lets others remix, tweak, and build upon your
work non-commercially, as long as they credit you and
Acknowledgements license their new creations under the identical terms.
Thank you to the following people who contributed their ideas
and support: Steve Connolly and Debbie Smith, Hodder Education; See - https://creativecommons.org/licenses/by-nc-sa/4.0/
Ray Chambers, Uppingham Community College; Miles Berry,
University of Roehampton; Roger Davies, Queen Elizabeth Although every effort has been made to ensure that website
School; Clare Riley, Jeannette Wing, Thomas Ball, Peli de Halleux, addresses are correct at time of going to press, Microsoft
Michal Moskal, Eric Anderson, Jonathan Protzenko, Steve Hodges, cannot be held responsible for the content of any website
Deirdre Quarnstrom, Vardhani Mellacheruvu, Lori Ada Kilty, Darren mentioned. It is sometimes possible to find a relocated web
Gehring, Genevieve Payzer, Gladys Hilerio, Kevin Chen, Michael page by typing in the address of the home page for a website
Braun and Judith Bishop from Microsoft and the BBC team. in the URL window of your browser.
Quick Start Guide for Teachers
The project aims to put digital creativity in the spotlight like never before,
and to help build the nation’s digital skills, through an ambitious range of
new programmes, partnerships and projects.
These include:
• A major partnership to develop and give a BBC micro:bit coding device
to all Year 7 children across the UK, for free, to inspire a future generation.
• A season of programmes and online activity involving the BBC’s biggest
and best-loved brands, including Doctor Who, Eastenders, Radio 1,
The One Show, Children in Need, BBC Weather and many more,
including a new documentary on Bletchley Park.
• The Make It Digital Traineeship to create life-changing opportunities for
up to 5,000 young unemployed people; the largest traineeship of its kind.
• Partnerships with around 50 major organisations across the UK.
• A range of formal education activities and events, including Bitesize,
Live Lessons and School Report.
As part of the Make It Digital initiative, the BBC has collaborated with over 25
organisations to create the BBC micro:bit, a personal programmable device,
which will be provided, free of charge, to every child in Year 7 across the UK.
02
The Make It Digital initiative
The device has a display made up of 25 LEDs and some simple input
controls that can be used in a number of ways. It is small enough
to slip into a pocket or even wear.
The BBC micro:bit also has Bluetooth Low Energy, allowing it to be part of
the ‘Internet of Things’ – the extension of the internet beyond computers and
smartphones to include other embedded systems, from fridges to cars, and
even home central heating systems.
Supporting learning
The BBC and its partners recognise that a hands-on learning experience can You can share links to tutorials
help young people to grasp the computing curricula in ways that on-screen and code with other BBC microbit
coding activities and traditional classroom learning cannot. users via the dedicated BBC
micro:bit CAS forum at:
The BBC micro:bit can help learners to develop their understanding of computingatschool.org.uk/
physical technology and computing, offering the opportunity to apply
complex thinking, analytical and problem-solving strategies.
Inspirational content on BBC radio and television will raise awareness of the
BBC micro:bit, while teachers, parents and young people will be encouraged
and supported to get the most out of the device through a rich range of online
resources and real-world events created by the BBC and partners.
Partnerships
More than 25 organisations have been involved in this pioneering partnership.
See www.microbit.co.uk/partners for more information.
03
Quick Start Guide for Teachers
Front of board
BUTTON B
See Button A.
HOLES
Holes for sewing,
mounting and
hanging.
04
GND 3V 2 The BBC micro:bit
1 0
Back of board B
A
PROCESSOR BATTERY
All the BBC This socket
micro:bit’s connects
programs and the external
any data are battery pack
stored on the (containing two
small silicon-chip AAA batteries)
micro-controller. to the board.
This tiny chip The battery
designed by pack is attached
ARM has 128kB physically to the
flash memory board with a
and 16kB RAM Velcro patch.
memory; a tiny
fraction of the
memory on a
smartphone.
COMPASS ACCELEROMETER
A sensor to detect magnetic fields, Converts analogue information about how quickly
like the Earth’s, allowing the direction the BBC micro:bit’s speed changes to a digital form
of the BBC micro:bit to be determined that can be used in BBC micro:bit programs. Output
and converted to a digital form from the accelerometer is in milli-g. Allows the BBC
that can be used in BBC micro:bit micro:bit to be used to control movement of on-screen
programs. Output from the compass characters such as Kodu.
is degrees.
ARM designs the processors for most mobile phones Machine code is the language the CPU (central
and embedded systems (such as smart thermostats, processing unit) of a computer understands, but it isn’t
car engine controllers and the processors inside digital very readable by humans as it is made up of numbers.
cameras), and was founded by members of the original
Machine code is known as a low level language. High
BBC Micro team!
level languages, such as Microsoft Block Editor or
BBC micro:bit is based on ARM’s mbed platform Microsoft Touch Develop, are readable/understandable
for embedded systems, but programming the by humans. A program written in a high level language,
BBC micro:bit is very straightforward. like Microsoft Touch Develop, has to be compiled
(translated) into machine code that the processor
‘understands’ (see page 10).
05
Quick Start Guide for Teachers
04 05 03 06 07 08 02 01 09
01 Sign in 02 My Scripts
Click on My Scripts to:
To sign in:
• save and retrieve scripts
• enter your facilitator code provided (email
• compile code and ‘flash’ it to a BBC micro:bit
[email protected] if you don’t have one)
• publish scripts to the BBC micro:bit website
• authenticate your account by entering a
• share scripts with other BBC micro:bit users
username and password from an existing
• set up groups, with access codes, for your
account (Facebook, Microsoft, Office 365)
students to join.
• read and agree to the terms of use.
06
The BBC micro:bit website
03 Create Code
Click here to choose and select an available code Microsoft Touch Develop Editor
editor (see below) to start creating programs for The Microsoft Touch Develop Editor sits between
the BBC micro:bit. visual, block-based languages, such as Blockly,
and traditional, text-based programming languages,
All code editors come with a BBC micro:bit simulator, such as Python. The editor is based on the Microsoft
so you can test ideas and code on screen without Touch Develop programming language and comes
having to have a BBC micro:bit plugged into the with a BBC micro:bit library of commands installed.
computer to run the code you write. Two key editors
are currently available to program the BBC micro:bit. Like other text-based programming languages,
Microsoft Touch Develop provides a great deal
Microsoft Block Editor of flexibility: as well as supporting input, output,
This is a graphical, drag and drop code editor, sequence, selection, repetition and variables,
where coding blocks snap together. It’s quite there’s also support for user-defined functions,
similar to Scratch, which many students may have making this a good choice for developing the ideas
encountered in primary school. There’s support for the of decomposition and abstraction.
main input and output functions of the BBC micro:bit,
as well as standard programming constructs such as Other code editors
sequence, selection, repetition and variables. A number of other code editors will be available
from the Autumn term 2015. See www.microbit.
It’s easy to start a project in Microsoft Block Editor co.uk/create-code for up-to-date information on
and then convert it to a Microsoft Touch Develop script. which code editors are available.
04 Discover 06 About
Everything you could want to know about your
Use this drop-down menu to explore the BBC
BBC micro:bit and its features.
micro:bit website, including tutorials and projects.
Tutorials
The BBC micro:bit site offers different types of 07 Getting Started
coding tutorials. Some tutorials are interactive
and lead you through the creation of a program
These are video and step-by-step guides for getting
step-by-step with on-screen tips. Others present
started with the BBC micro:bit. These videos and
guided challenges with fewer instructions. Here
guides walk you through the process of starting to
we provide support by signposting key instructions
write some code, including switching between the
and routes through projects.
different code editors available, saving projects,
Projects installing the loader software on your computer,
This is a bank of BBC micro:bit projects created connecting the BBC micro:bit and uploading code
by other coders for you to explore, use and adapt. to it via the loader. This content will be continually
Some of these projects have been created by the updated.
BBC and BBC micro:bit partners, but most will be
written by young people themselves and other BBC
micro:bit users. These are a great starting point for
seeing just what the BBC micro:bit can do, as well
08 Teachers and Parents
as learning how to program it. It’s much easier to This introduces the BBC micro:bit in the context of
take someone else’s program and edit it to make it its use in the classroom and at home. It contains
work a little (or a lot) differently, than having to start useful information for anyone supporting children
programming from a blank screen. on their BBC micro:bit journey.
05 Search 09 Help
Search through learning resources, videos, Here you will find frequently asked questions and
tutorials and more. where to go for additional support.
07
Quick Start Guide for Teachers
04
Have a go at clicking some of the buttons on screen to see what they do.
08
Getting started with the Microsoft Touch Develop Editor
05
Click on the led->plot(2, 2) instruction that’s already in the script. A code keyboard will appear at the
bottom of the screen.
CODE KEYBOARD
The keyboard makes it easy to
edit your code on a touch screen
device or just using a mouse.
If you’re working with a normal
keyboard, you can enter language
commands by just typing, and
you’ll see the possible command
completions appear automatically.
Where next?
Use Microsoft Touch Develop
Get coding using the lessons on pages 12–30 in There’s more to Microsoft Touch Develop than the
this book. Once you’ve completed all four, visit BBC micro:bit! Visit touchdevelop.com to make
www.microbit.co.uk/start-guide/certificate games and apps and stretch your digital creativity!
to pick up your certificate!
09
Quick Start Guide for Teachers
C++
Compiler
mbed C++
SDK
2
ARM 2 User
accepts
download
of
ARM
binary.
mbed
compile
service
ARM
binary
program
Azure
10
Coding building blocks
11
Quick Start Guide for Teachers
Display of a Creeper face (similar to the character seen This lesson can be decomposed into four parts:
in Minecraft) on the BBC micro:bit LED display:
1. Design how our single state will look (which LEDs
• By default, all of the LEDs (or lights) are off. will be switched on to display our Creeper face).
• There will be a single state (Minecraft Creeper face). 2. Use the image editor to turn on the required LEDs.
• The image will turn off after 3 seconds. 3. Create a timer to pause the image for 3 seconds.
4. Reset the display to its original state: OFF.
Tutorials
01
Draw a 5×5 grid and colour in the boxes to show Key Why not try
what the Minecraft Creeper face will look like. LED on = out different
images?
You don’t have to program a Creeper face. LED off =
The image could be anything you like.
CREEPER FACE
02
Start by opening a new browser window and typing
www.microbit.co.uk in the address bar.
12
Lesson 1: Digital key chain
03
A blank coding environment will appear
(see picture to the right).
04
The Images section includes blocks that control
the creation and display of an image on the BBC
micro:bit through LEDs.
05
You will notice that an offset value of 0 is displayed.
06
We now want to select which LEDs will be
ON for our Creeper face.
07
Drag the create image block into the empty
position on the show image block.
It’s important that we test our programs regularly. This allows us to debug the program
and fix any errors.
13
Quick Start Guide for Teachers
08
Press the run button to test your program.
What does it look like on the simulator?
If it doesn’t work as expected, go back and
try to find and correct the problem.
09
From the Basic menu, select the pause block.
The BBC micro:bit uses milliseconds as input, so
1000 is equivalent to 1 second.
10
Click on the LED menu. Select the clear screen
block and snap it under the pause block. This will
make sure that all of the LEDs are turned off after
the Creeper face has displayed for 3 seconds.
11
You should now have a finished program
which will display a Creeper face!
A solution for the complete digital key chain code can be found on page 31. The working
code can be found at www.microbit.co.uk/start-guide/solutions/digital-key-chain.
14
Lesson 2: Rock, paper, scissors game
A simple ‘rock, paper, scissors’ game. Each time you This lesson can be decomposed into five parts:
shake the BBC micro:bit, it will randomly choose one of
three shapes: rock, paper or scissors. 1. Design how each shape will look.
2. Create an image that contains three frames; one for
Tutorials each of the three shapes.
3. Randomly generate an offset that will choose which
For a guided tutorial, go to www.microbit.co.uk/td/ of these three frames is displayed.
lessons/rock-paper-scissors/tutorial 4. Display the image on the BBC micro:bit.
5. Create an event handler to detect when the BBC
micro:bit is shaken.
01
Draw three 5×5 grids and colour in the boxes
(representing LEDs) to show what the rock, paper
and scissors images will look like.
02
Open a new browser window and type
www.microbit.co.uk in the address bar. Click on
Create Code. In Microsoft Touch Develop, click
New project. Type in a name for your script, such
as rock paper scissors. Click on create.
15
Quick Start Guide for Teachers
03
We need to start by creating an image that
contains three frames: rock, paper and scissors.
Click on do nothing and then select image,
followed by create image.
04
Next, select the 5×5 grid (representing the BBC
micro:bit LEDs) to create each frame. This will bring
up a visual editor, which allows you to control which
of the LEDs you want to turn on for a given frame.
05
Add two more frames to the editor by clicking on
add frame twice.
06
Now, click on the LED boxes corresponding to
those you coloured in for step 1, so that each frame
represents one of the three shapes. Click on the ok
button when you have finished.
07
Now we need to store this image in a variable.
Click store in variable from the keyboard
Using offset
Offset allows us to specify the number of pixels the image is shifted to the right or
left on the BBC micro:bit display. We will use offset to choose the frame in our img
variable that we want to show.
16
Lesson 2: Rock, paper, scissors game
08
The BBC micro:bit will show one frame of our image
at a time by displaying the image with an offset of
either 0, 5, or 10. (An offset of 0 will display the first
image, 5 the second and 10 the last.)
We want the BBC micro:bit to randomly choose one
of these offset values when we run the script.
Add a new line of code by clicking the + button.
Then click math followed by random. By default,
the random number generator has a limit of 2. This
means that it will randomly generate a number
between 0 and 1. We need to generate three random
numbers, so to fix this, change the 2 inside the
brackets to a 3.
09
We have created code to generate a random
number between 0 and 2. But we actually need
our BBC micro:bit to randomly generate either
0, 5, or 10 (to match our offset values). We can
resolve this by multiplying the randomly generated
number (between 0 and 2) by 5 (resulting in either
0, 5 or 10). Use the keyboard to insert * and then
type 5 (as shown).
10
We have created a random number that is either
0, 5, or 10. However, the value will be lost if we
don’t do anything with it. Let’s store it in a variable
that’s called offset. Click store in variable from
the keyboard. Rename x to offset.
11
Now we need to display the image with the
appropriate offset on the BBC micro:bit. Add a
new line of code by pressing the + button. Then,
on the keyboard click img and then show image.
This will display the image on the BBC micro:bit.
12
By default, the offset of the show image is 0, as
indicated by the number in the brackets. However,
we want to replace the 0 with the variable offset
that we generated in steps 8–11. Delete the 0,
and then select the offset variable from the
keyboard below.
17
Quick Start Guide for Teachers
13
Start by adding an on shake condition to detect
when you shake the BBC micro:bit. Add a new line
of code, then click on input followed by on shake.
(You may need to click on more to display the
input option.)
14
You have created the event handler, but nothing
will happen yet when the BBC micro:bit is shaken.
We need to fix this by moving all the code we have
created so far into the on shake condition. Begin by
selecting the first line of code and then clicking cut.
15
Select the do nothing line inside the on shake
event handler, and then click paste. Cut and paste
the remaining two lines of code so that your screen
looks like the image on the right.
Do it yourself!
Can you program the BBC micro:bit to track the scores of your games with the BBC micro:bit?
- You will first need to create a variable for the times you win against the BBC micro:bit.
- Add code so that your score goes up each time you press Button A.
- Add code to display the score on the BBC micro:bit.
- Repeat the previous step for when you lose against the BBC micro:bit. Add code to reduce your score each
time you press Button B, then display the score after either button is pressed.
A solution for the complete rock, paper, scissors game code can be found on page 31. The solution to
these challenges can be found at www.microbit.co.uk/td/lessons/rock-paper-scissors/challenges.
18
Lesson 3: Digital pet
A digital pet (similar to Tamagotchis from the 1990s) This lesson can be decomposed into four parts:
with different states that can be controlled by pressing
Buttons A and B (our input). The idea is that our digital 1. Design how each state will look
pet needs to be taken care of. (which LEDs will be switched on).
2. Create a function that tells our BBC micro:bit
• The default state of the pet is AWAKE. which LEDs to turn on for each state.
• Button A will stroke the pet, causing it to fall ASLEEP. 3. Create a forever loop to continually update the state.
• Button B will feed the pet, so it is EATING. 4. Create conditional statements to specify which
function to run if a particular button is pressed,
Tutorials e.g. if Button A pressed then go to ASLEEP state.
01
Draw a 5×5 grid and colour in the boxes
(representing LEDs) to show what your pet will
look like at different times, for example: AWAKE,
ASLEEP, EATING (as shown on the right).
02
Start by opening a new browser window and typing
www.microbit.co.uk in the address bar. Click on
Create Code. In Microsoft Touch Develop, click
New project. Type in a name for your script, such
as Digital pet. Click on create.
19
Quick Start Guide for Teachers
03
To create the first function (for our AWAKE face),
select the script button in the top right of the
screen. Click on the add new (+) button to bring
up your resource menu.
04
Select function from the menu. This will bring
you to a new coding area (as shown on the right).
Notice that it will say do stuff at the top. This
is the current name of the function. Click on do
stuff and rename your function to set awake.
Click ok.
05
Now that we have named our function, we need
to specify which LEDs should be turned on for the
AWAKE state. We can do this using the image
editor. Click do nothing in the coding area. A
keyboard will pop up at the bottom of the screen.
Select image. Notice how the keyboard changes.
Select create image.
06
Click on the 5x5 grid within the brackets. You
will notice that none of the LEDs are currently
lit. Select the LEDs that you want to be on when
your digital pet is in the AWAKE state. When you
have finished, click on ok at the bottom right of
the pane.
07
You’ll notice an error message below your line of
code. The BBC micro:bit has created an image,
but the image will be lost if we don’t do anything
with it. Let’s store this image in a variable and
name it img. Click on store in var at the bottom
to store this image.
20
Lesson 3: Digital pet
08
To show this image on the BBC micro:bit, click the
+ button to create a new line of code. Click on the
image variable name img.
09
To display this image, click on show image.
10
We have created a function to display our digital
pet in its AWAKE state. However, this function
isn’t yet ‘called’ by the main method. Go back to
the main method by clicking on script followed by
main. Click on do nothing, then code, followed by
set awake.
11
Now let’s create another function to put our digital
pet to sleep. Click on script, followed by add new,
and then function. Rename the script to set
sleep using the same method as you did for
set awake.
12
Just as you did for set awake, create an image for
the sleep mode and store it in a variable named
img. You can do this by clicking on image and
then create image. Next, click on the 5x5 grid.
Plot the LEDs as shown, and click on ok when
you are finished. Finally, click on store in var
at the bottom.
21
Quick Start Guide for Teachers
13
After you have stored the picture in a variable,
don’t forget to display it as well! To do this, click on
the + button to insert a new line of code and select
img followed by show image.
14
Click on script and main to return to our main
method. To create a forever loop so that our
program will continuously update the state of our
digital pet, click on the + button to add a new line of
code, then click on basic, followed by forever.
15
We now need to add an IF statement to specify
which function to run when Button A is pressed.
When Button A is pressed, we want to display the
ASLEEP state. Click do nothing, and then if. Now,
we need to add a condition within the IF statement.
We want to know if Button A is pressed, so click
input, button is pressed followed by "A".
16
Now we need to display the SLEEP state when
Button A is pressed. Inside the IF statement, call
the function, set sleep. You can do this by clicking
on do nothing below the IF statement, then code,
followed by set sleep.
22
Lesson 3: Digital pet
17
At the moment, our digital pet will be set to sleep
for only a split second because the forever loop
executes the code very quickly. So, let’s add a
pause of 5000 milliseconds (5 seconds) after our
pet is set to sleep. To do this, add a new line of
code by clicking the + button, then select basic,
followed by pause. Change 100 to 5000.
18
We now have code that specifies what happens
when Button A is pressed. But what happens
if Button A is not pressed? We want the default
state for our pet to be AWAKE so we need to move
set awake to inside the ELSE statement, which is
found below the IF statement. To do this, select
set awake and then click on the cut button.
19
Now, select do nothing inside of the ELSE
statement, and select paste.
Do it yourself!
- Can you add another function called set eat so that you can feed your pet?
- Try to feed your pet using Button B.
- Can you add code so your pet tells you when it is going to sleep?
- Can you keep track of how many times you feed your pet, and display that number when the BBC micro:bit
is shaken?
A solution for the complete digital pet code can be found on page 31. The solution to these
challenges can be found at www.microbit.co.uk/td/lessons/digital-pet/challenges
23
Quick Start Guide for Teachers
A ‘catch the egg’ game in which an egg (represented This lesson can be decomposed into seven parts:
by a single LED) ‘falls’ from the top of the BBC micro:bit
display and can be caught in a moveable basket at the 1. Create the global variables for the game.
bottom of the display. The script includes code for the 2. Assign initial values to each of the global variables.
accelerometer, which allows a user to control the 3. Plot the starting positions of the LEDs.
position of the basket when the device is tilted: 4. Create a forever loop to update the display regularly.
• By default, the first ‘egg’ LED starts to drop from 5. Get the ‘egg’ to drop down the LED display.
the centre of the top line of the display. 6. Change the position of the basket using the
• The subsequent ‘eggs’ will then fall from random accelerometer functionality.
positions at the top of the display. 7. Use IF conditions to check the final position of the egg.
• The ‘basket’ will be moved by tilting the
BBC micro:bit.
Tutorials
01
Start by opening a new browser window and typing
www.microbit.co.uk in the address bar. Click on
Create Code. In Microsoft Touch Develop, click
New project. Type in a name for your script, such
as Catch the egg. Click on create.
02
We’re going to start by creating a number of global
variables that will be accessible from any part of
our program. To begin, click on the script button in
the top right-hand corner.
24
Lesson 4: Catch the egg game
03
A menu will pop up, which allows you to add other
features to your program. In this case, we’re going
to add in a global variable by clicking on the +
button.
04
Select the data button from the menu that
appears.
05
Now it’s time to select a data type. For this
program we’re going to use Number for our
variables. This is because we’re going to be using
x and y coordinates to designate the position of our
basket to catch the falling eggs.
06
We’re going to start by creating a variable for the
x-position of the basket we will use to catch the
egg. Type in basket x, then click the ok button.
You should see your basket x variable in vars.
Naming variables
Explain, or remind students, to be as descriptive as possible when naming variables
(e.g. score, timer, etc.) rather than using generic names (e.g. variable 1, variable 2,
etc.). It’s much easier to find and fix problems with variables when you can easily
work out which one isn’t working.
25
Quick Start Guide for Teachers
07
Repeat steps 2−6 to create all the variables for
your game. You will need to create three variables
in total: basket x, egg x (to control the
horizontal position of the egg) and egg y
(to control the vertical position of the egg).
08
Return to your main function. Click do nothing
below the main function, then select the data
button from the keyboard.
09
Select the variable basket x to begin with.
Remember: basket x controls the x-position
of the basket.
10
To assign a value to the basket x variable, select
the assignment (:=) button from the keyboard.
We want the basket to sit in the centre of the
bottom row of the display, so type in 2. Click on
the + button below the basket x variable to add
lines for the other two variables.
11
Assign values to the remaining two variables by
following the step above. We want the egg to
start falling from the top centre of the display at
the beginning of our program, so set egg x to 2
(middle) and egg y to 0 (top).
26
Lesson 4: Catch the egg game
12
Click the + button to add another line of code
below your assigned variables. Select led from
the keyboard and then select the plot button (on
screen 2 of the keyboard). You should now have
something which looks like the image shown on
the right.
13
The code shown above will only turn on a LED at
position (0,0). We need to remove each of these
values and replace them with our egg x and egg y
value. Delete the first 0 and replace it with egg x.
Repeat this process to select egg y for the
second 0.
14
We now need to plot the starting position of the
basket (basket x). Click the + button to add a new
line of code. Then select led from the keyboard
and then select the plot button. Change the first 0
to the basket x variable and the second 0 to 4.
15
At this point in the program we’re going to run the
script by selecting the run button. You should see
something similar to the simulator on the right
when you run your program.
27
Quick Start Guide for Teachers
16
Add a new line of code by pressing the + button.
Select basic, and then forever.
17
Before we can light up the second LED (below
the first), we need to unplot the original LED. This
will ensure a smooth transition from one lit LED
to another – to create the impression the egg is
falling. Select led from the keyboard and unplot.
Unplot both your basket position (basket x) and
your egg position (egg x, egg y), as shown in
the picture.
18
To get the egg to move down the display, we need
to change the vertical position of the egg (egg y).
We can do this by adding 1 to the value of egg
y, each second. Select egg y and assign (:=) the
variable to egg y + 1.
19
You now need to plot the egg in its new position,
using plot as we have previously (see step 12).
We will need to slow down the movement of the
egg. Select basic and pause, and input 300
milliseconds. This will allow you to see the lights
fall down the screen at a slower pace.
Run your program, you should notice the egg fall down the board.
28
Lesson 4: Catch the egg game
20
We’re going to add the next line of code above
the pause. Select input from the keyboard. To
use the accelerometer you will need to select the
acceleration button. Now select store in var. The
program sets the acceleration to left and right. This
is the default position ("x"); you can also control up
and down ("y"). You should have something like this:
21
We now need to work out the position of the
accelerometer and then turn the LEDs on. Select
the basket x variable from the data menu in the
keyboard. Select the assignment (:=) button.
22
Type in number 2, + and then select the math
library from the menu at the bottom. We need the
math library in Microsoft Touch Develop so that we
can do our maths calculations and work out the
position of the accelerometer.
23
Select the min button. Replace the first number
with 2 and then math and then max. This code
is finding the highest and lowest values that the
board could move to the left and right. Your code
should look like the picture, on the right.
24
To finish, we need to replace the maximum values
with -2 and then the variable we created. In this
case it’s called acc x. Divide it by 200.
29
Quick Start Guide for Teachers
25
You now need to add a line above the pause line
to plot the basket. To do this, select led and plot
and click on data to use basket x.
26
Select if from the menu and create a conditional
statement for if egg y is greater than 4. This
means the egg is off the display because 4 is the
bottom of the board.
27
Inside this IF statement, we’re going to tell the
egg to find a new position at the top of the screen.
We’re going to set the value to -1 so that the egg
is hidden just above the board before it appears
at 0. We’re then going to set the position of egg x
using the math library to find a random value.
Can you repeat the code shown? If you test your
program now, you will notice that the egg keeps
falling down the screen in random positions.
A solution for the complete catch the egg game code can be found on page 31. The solution to these
challenges can be found at www.microbit.co.uk/td/lessons/catch-the-egg-game/challenges
30
Solutions
Solutions
31
Quick Start Guide for Teachers
understand several key algorithms that reflect There’s scope here to get students thinking algorithmically,
computational thinking [for example, ones for sorting and carefully planning their programs before they write any
searching]; use logical reasoning to compare the utility of code. Some key algorithms could be implemented on the
alternative algorithms for the same problem BBC micro:bit too, from finite state machines (Lesson 3:
Digital pet) to ‘guess my number’ games using binary
search.
use two or more programming languages, at least one Students could compare programming the same algorithm
of which is textual, to solve a variety of computational in both the Microsoft Block and Microsoft Touch Develop
problems; make appropriate use of data structures [for Editors. They can also learn to design and develop
example, lists, tables or arrays]; design and develop modular programs using user-defined functions in
modular programs that use procedures or functions Microsoft Touch Develop.
understand simple Boolean logic [for example, AND, There’s chance to explore Boolean logic using the AND,
OR and NOT] and some of its uses in circuits and OR and NOT operators built in to the language and the A
programming; understand how numbers can be and B input buttons on the BBC micro:bit.
represented in binary, and be able to carry out simple
operations on binary numbers [for example, binary addition, The 25-pixel display lends itself to investigating binary
and conversion between binary and decimal] representation, both for images, creating simple bitmap
sprites, and for numbers, using it to display numbers up
to 225 using binary place value! Why not create a binary
counter or even a clock using the BBC micro:bit?
understand the hardware and software components that As it’s a simple system, the BBC micro:bit provides a
make up computer systems, and how they communicate more accessible way for students to grasp complex ideas
with one another and with other systems of how hardware and software systems behave and
communicate.
understand how instructions are stored and executed within The use of compiled machine code here might be part of
a computer system; understand how data of various types a unit of work exploring how instructions are stored and
(including text, sounds and pictures) can be represented executed in computers.
and manipulated digitally, in the form of binary digits
undertake creative projects that involve selecting, using, There’s ample scope for creative projects here, achieving
and combining multiple applications, preferably across a challenging goals and meeting the needs of known users.
range of devices, to achieve challenging goals, including The limitations of the BBC micro:bit interface make it a
collecting and analysing data and meeting the needs of great way to think creatively about design and usability.
known users
create, re-use, revise and re-purpose digital artefacts for Remixing code via the BBC micro:bit site provides some
a given audience, with attention to trustworthiness, design great opportunities for working with ‘digital artefacts’
and usability produced by others.
understand a range of ways to use technology safely, Participating in the BBC micro:bit online community
respectfully, responsibly and securely, including protecting provides an opportunity to emphasise the need for respect
their online identity and privacy; recognise inappropriate and responsibility when working online.
content, contact and conduct and know how to report
concerns
32
The BBC micro:bit Quickstart Guide for Teachers is designed
to support educators in effective use of the BBC micro:bit devices
distributed to all Year 7 students in the United Kingdom as
part of the BBC’s Make It Digital initiative.
• Advice on how teachers and students can get the most out of the
BBC micro:bit device, including how the hardware and supporting
services work (including the BBC micro:bit website, code editors
and code compiler)
• Guidance on how to get started with creating programs for the BBC
micro:bit using the Microsoft Touch Develop Editor, and how to
compile them and upload them to your device