Program a micro:bit with blocks in the simulator. Pictures, loops, buttons, variables, sensors, decisions and lists, ending in a pocket pet you build yourself.
Each lesson works two ways. Students can work through the online tutorial at their own pace (it checks their answers and saves their progress in their browser), or you can teach it to the whole class from the slides, then send students into the tutorial for the Modify and Make steps.
Every lesson guide has plain-language notes, the answers to every check, a solution for every task, and slides and a worksheet for Waypoints Prepare. These guide pages are not linked from student pages, but they are not secret either: keep printed Teacher editions for answers you do not want students to find.
Whole-course cheat sheet: Open to print (every command, grouped by unit: a handout for the final challenge)
Pictures in order, loops that repeat, and code that waits for a button.
A micro:bit program is blocks that run in order, from top to bottom. Where you put a block decides when it runs:
The simulator (the picture of a micro:bit beside the blocks) runs the program straight away, so no real micro:bit is needed.
Almost every device works this way. A pedestrian crossing loops through its lights, and a doorbell waits for a press. Knowing which blocks run once, which repeat and which wait is the first step to making a device do what you want.
on start is a morning announcement: it is read out once. forever is a looping playlist. An event block is a doorbell: it does nothing until someone presses it, and then rings every single time.
Where it breaks: a doorbell checked only during the morning announcement would never ring. That is the most common bug: checking a button in on start, which looks once and never again.
Every later unit builds on these three holders: a button changes a variable, forever checks a sensor and decides, and in the next course radio adds a new event, on radio received.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
A variable that counts, and sensors that give numbers.
A variable is a named box that holds a value, such as count. Two blocks change what is in the box:
A sensor measures the world and hands the program a number: light level (0 dark to 255 bright), temperature (degrees Celsius), acceleration (tilt: below 0 one way, above 0 the other). A sensor is like a variable that the world keeps changing. The program only sees a new value when it reads the sensor again.
Every device that counts or measures needs both: a step counter keeps a variable and changes it on each shake; a thermostat reads a temperature sensor again and again. Programs are mostly about keeping track of numbers like these.
A variable is a tally on a whiteboard. Change by 1 adds a stroke; set to 0 wipes the board. A sensor is the thermometer on the wall: it keeps changing whether or not anyone looks.
Where it breaks: wiping the board inside forever happens many times a second, so the tally is always 0. And looking at the thermometer once (in on start) tells you the temperature at the start, not now.
The Decide unit asks questions about these numbers (if light level < 50), and the challenge keeps a best score in a variable.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
If, else and else if: the micro:bit chooses what to do.
An if block asks a yes-or-no question (a condition), such as light level < 50. When the answer is yes (true), it runs the blocks inside. When it is no (false), it skips them and does nothing.
else adds an "otherwise": exactly one of the two parts runs. else if adds more questions. The micro:bit asks them from the top, runs the first true one and skips the rest. else runs only when none are true.
Comparisons are in Logic: < less than, > greater than, ≤ and ≥ with "or equal to".
Decisions are what make a device respond: street lights switch on in the dark, a fridge beeps when it is too warm, a phone rotates its screen when tilted. Each one is a sensor number and a question.
A security guard at a door with a list of questions, asked in order: "Are you staff? Go in. Otherwise, are you a visitor? Sign in. Otherwise, wait here." The first yes decides what happens, and nobody is asked the later questions.
Where it breaks: if the first question is too wide ("Are you a person?"), everyone goes in and the later questions never get asked. That is why the order of else if matters: ask the narrow question first.
The Pocket pet challenge turns its hunger number into a face with if … else if … else. In the next course, decisions check which radio message arrived and whether a press came too early.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
Many values under one name: pick one by its place, or at random.
A list (MakeCode calls it an array, in Advanced › Arrays) holds many values in order under one name, such as answers. Each item has a place (an index) counted from 0, so a list of 3 uses places 0, 1 and 2. get value at takes out the item at a place.
pick random (in Math) gives a whole number between two numbers, a new one each time. length of array counts the items. To pick an item at random: get value at (pick random 0 to length − 1). Using the length means the list can grow without changing anything else.
Lists keep many related values together (a playlist, a menu, a class roll), so one block can work with any of them: the item at a place a button chose, or the item at a random place.
A list is a row of numbered lockers, starting at locker 0. Picking at random is drawing a locker number from a hat.
Where it breaks: people count from 1, so locker 3 in a row of 3 does not exist. And a hat that still holds only the numbers 0 to 2 never picks the two lockers added later: a fixed range on a list that grew.
The Pocket pet picks a trick at random from a list. In the next course, a list both micro:bits share becomes a code for radio messages.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
Build a pet that gets hungry, eats and does tricks, in three milestones.
The challenge builds a pocket pet: a pet that lives on the micro:bit. It uses every lesson in the course and adds nothing new.
hunger, go up by itself as time passes.It is built in three milestones with less help each time: most of the steps, then an outline, then a goal only. Pocket pet marks the course Challenge complete.
Real programs are combinations: state (variables), time (loops), events, decisions and data (lists) working together. A pet makes the combination visible, and students can test it by looking after it.
A pet is a fuel gauge with a face: time drains it, you top it up, and the face shows how full it is.
Where it breaks: a gauge that never drains by itself is not a pet. In code, that is a change block outside forever: hunger never moves unless someone presses a button.
The next course, micro:bit: talk and play, names jobs as functions, connects micro:bits by radio and measures time, ending with a reaction game and a radio duel.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
Self-paced briefs students can pick up after the lesson named on each. Students tick their own milestones and claim a badge; the page lights the skills their code uses. Badges stay in the student's browser: ask them to press Show your teacher. Open the projects page
Make a plant monitor for a windowsill: it reads the light and the temperature, and its face tells you whether the plant is happy, too dark or too hot. What counts as too dark or too hot is up to you (look up what your plant likes).
Milestones:
The common gap is question order: a wide question asked first ("light level < 200") hides the narrower ones after it. Ask "which face shows when it is dark and hot at the same time, and is that the one you want?".
let checks = 0
basic.forever(function () {
if (input.lightLevel() < 40) {
basic.showIcon(IconNames.Asleep)
} else if (input.temperature() > 30) {
basic.showIcon(IconNames.Sad)
} else {
basic.showIcon(IconNames.Happy)
}
checks += 1
basic.pause(1000)
})
input.onButtonPressed(Button.A, function () {
basic.showNumber(checks)
})
Make a micro:bit that answers questions: shake it and it picks an answer from a list (a Magic 8-ball, a dinner chooser, a "who goes first" picker, a dice for a board game). The answers are yours.
Milestones:
"Every one can come up" is the list-length check in disguise: a random place from 0 to the length minus 1. Students who type a fixed number there miss the last answer when the list grows.
let answers = ["YES", "NO", "MAYBE", "ASK AGAIN", "DEFINITELY"]
input.onGesture(Gesture.Shake, function () {
basic.showString(answers[randint(0, answers.length - 1)])
})