Students store the running time at one moment and take it away from a later reading, to measure how long something took.
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 10 min · Modify 8 min · Mix it up 3 min · Make 8 min · Egg timer 3 min
running time (Input › more) is the number of milliseconds since the micro:bit switched on. It never restarts at a press, so on its own it is a big number. Timing is a subtraction: store running time in a variable at the start (start), then later show running time − start. 1000 ms is one second; dividing by 1000 gives seconds with a decimal. In the simulator, timings are a little longer than on a real micro:bit.
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.
Read the classroom clock and write the time. In one minute, read it again. How long passed?
Nobody restarts the wall clock to time something: we subtract two readings. That is running time − start.
Try the reaction make three times each with the next pair. Who is fastest?
Seeing why the subtraction is needed. Ask what running time was when the micro:bit started, and what it is now.
| What you will see | A question to ask | The fix |
|---|---|---|
| The time shown is huge, like 15000. | Is start set before the time is shown? | Set start to running time at the moment the timing begins. |
| The time shown is negative. | Which way round is the subtraction? | running time − start: the later reading first. |
| B shows 0 every time. | Is start set in the same event that shows the time? | Set start in A (or when the heart appears), and show the time in B. |
One possible solution for each task. Other correct programs are fine.

let start = 0
input.onButtonPressed(Button.A, function () {
start = input.runningTime()
basic.showIcon(IconNames.Yes)
})
input.onButtonPressed(Button.B, function () {
basic.showNumber((input.runningTime() - start) / 1000)
})

let start = 0
input.onButtonPressed(Button.A, function () {
start = input.runningTime()
basic.showIcon(IconNames.Yes)
})
input.onGesture(Gesture.Shake, function () {
start = input.runningTime()
basic.showIcon(IconNames.Yes)
})
input.onButtonPressed(Button.B, function () {
basic.showNumber((input.runningTime() - start) / 1000)
})

let start = 0
input.onButtonPressed(Button.B, function () {
basic.clearScreen()
basic.pause(randint(1000, 4000))
basic.showIcon(IconNames.Heart)
start = input.runningTime()
})
input.onButtonPressed(Button.A, function () {
basic.showNumber(input.runningTime() - start)
})
Open task: any program that does what the step asks.
Stretch: Make a lap timer: B shows the time since the last B, not since A (set start again after showing).
Support: Give students the make with start already set when the heart appears, and ask them only to build the subtraction in A.
start is 3000. Running time is 3750 when B is pressed. What does running time − start show, and what does it mean?
750: 750 milliseconds passed between storing start and pressing B.
Next lesson: a true/false variable, so an early press does not count. Class idea: time how long the class takes to go silent after the quiet signal.