Students use a variable to count button presses and shakes, and see the difference between setting a variable and changing it.
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 8 min · Mix it up 3 min · Make 10 min · Scoreboard 4 min
A variable is a named box that holds a value, such as count. Make one in Variables › Make a Variable. Two blocks matter: set puts a new value in the box (throwing the old one away) and change adds to what is already there. Where the set block goes matters: in on start it runs once; in forever it runs again and again and wipes the count. Numbers above 9 scroll across the screen, so ask students to wait before pressing again.
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.
A student holds a box with a number card in it. The class calls "A" (add one: swap for the next card) or "B" (set to 0: swap for the 0 card).
The box keeps its card between calls. That is what remembering means.
Swap step counters with the next pair. Shake five times, then check with A.
Telling set from change. Ask what count was before the press, and what it is after.
| What you will see | A question to ask | The fix |
|---|---|---|
| The number always shows 0. | Where is your set count to 0 block? | Move it into on start. In forever it resets the count all the time. |
| The count goes up but nothing shows. | Which block shows the number, and when does it run? | Add show number count inside the button event, after the change block. |
| Numbers above 9 seem to go missing. | What happens when the screen is still scrolling? | Wait for the number to finish scrolling, or press more slowly. |
One possible solution for each task. Other correct programs are fine.

let count = 0
basic.showNumber(count)
input.onButtonPressed(Button.A, function () {
count += 2
basic.showNumber(count)
})

let count = 0
basic.showNumber(count)
input.onButtonPressed(Button.A, function () {
count += 2
basic.showNumber(count)
})
input.onButtonPressed(Button.B, function () {
count += -1
basic.showNumber(count)
})

let steps = 0
input.onGesture(Gesture.Shake, function () {
steps += 1
})
input.onButtonPressed(Button.A, function () {
basic.showNumber(steps)
})
input.onButtonPressed(Button.B, function () {
steps = 0
basic.showIcon(IconNames.Yes)
})
Open task: any program that does what the step asks.
Stretch: Make the scoreboard show both scores on A+B, one after the other.
Support: Give students the step counter's three event blocks already in place, and ask them only to fill in set, change and show.
What is the difference between set count to 0 and change count by 1?
set count to 0 throws the old value away and puts 0 there. change count by 1 adds 1 to whatever count already is.
Next lesson: sensors give numbers too, but the micro:bit updates them by itself. Class ideas: a class tally of votes with A and B; count the steps between classrooms with a real micro:bit in a pocket.