Students name a job as a function and call it from several places, and see in Python that every event block is a function the micro:bit calls.
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Predict and Run 8 min · Investigate 12 min · Modify 10 min · Mix it up 3 min · Make 9 min · Alarm 3 min
A function is a named job: some blocks with a name, made once in Advanced › Functions. Making it does not run it. It runs when a call block calls it, once per call. One copy serves every call, so a change to the function reaches every place at once; copied blocks have to be changed in every copy. The Python button at the top of the editor shows the same program as text: every event block (on button A pressed) becomes a function, handed to the micro:bit to call. Students only read the Python. Functions with inputs (parameters) come later, in Secret messages.
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
The class agrees one move, 'the wave' (two arm positions). The teacher calls "wave, wave, jump"; students do each move when it is called, and not before.
Agreeing the move is making the function; calling its name runs it.
Perform your micro:bit's dance for the next pair: they press the buttons, you name the function each one calls.
Making a function does nothing until it is called. When a press does nothing, ask which block calls the function.
| What you will see | A question to ask | The fix |
|---|---|---|
| Nothing happens when the button is pressed. | Which block calls your function? | Add a call block (from Functions) inside the button event. |
| The call block is missing from the toolbox. | Have you made the function yet? | Make the function first; its call block then appears under Functions. |
| The student copied the flash blocks instead of calling. | If you change the picture, how many places must you change? | Delete the copy and call the function instead. |
One possible solution for each task. Other correct programs are fine.

function flashHeart () {
basic.showIcon(IconNames.Heart)
basic.pause(200)
basic.clearScreen()
basic.pause(200)
}
input.onButtonPressed(Button.A, function () {
flashHeart()
flashHeart()
})
input.onButtonPressed(Button.B, function () {
flashHeart()
flashHeart()
flashHeart()
})

function flashHeart () {
basic.showIcon(IconNames.Heart)
basic.pause(200)
basic.clearScreen()
basic.pause(200)
}
function flashSad () {
basic.showIcon(IconNames.Sad)
basic.pause(200)
basic.clearScreen()
basic.pause(200)
}
input.onButtonPressed(Button.A, function () {
flashHeart()
flashHeart()
})
input.onButtonPressed(Button.B, function () {
flashHeart()
flashHeart()
flashHeart()
})
input.onGesture(Gesture.Shake, function () {
flashSad()
})

function wave () {
basic.showLeds(`
. . # . .
# . # . #
. # # # .
. . # . .
. # . # .
`)
basic.showLeds(`
. . # . .
. . # . .
# # # # #
. . # . .
. # . # .
`)
}
function jump () {
basic.showLeds(`
. . . . .
. . # . .
. # # # .
. . # . .
. # . # .
`)
basic.showLeds(`
. . # . .
. # # # .
. . # . .
. # . # .
. . . . .
`)
}
input.onButtonPressed(Button.A, function () {
wave()
wave()
})
input.onButtonPressed(Button.B, function () {
jump()
jump()
})
input.onGesture(Gesture.Shake, function () {
wave()
jump()
})
Open task: any program that does what the step asks.
Stretch: Make a third move and a routine of all three, called from A+B.
Support: Give students the two dance functions already made with one picture each, and ask them to add a second picture and the calls.
You make a function, but never call it. What happens when the program runs?
Nothing from that function: its blocks only run when something calls it.
Next unit: radio. on radio received is one more event block, so one more function the micro:bit calls. Class idea: a class dance where each group writes one move as a function.