Reaction timer

Wait for the dot, then press A as fast as you can: learners time their reactions in milliseconds and analyse the class's data.

Go to the code ↓

Lesson at a glance

45 to 60 minutes · Grades 6 to 9

maze.education/microbit/lessons/reaction-timer

Grades
Grades 6 to 9
Time
45 to 60 minutes
The CAPS gives Coding and Robotics 2 hours a week (Coding and Robotics CAPS, Grades 4 to 6, page 22; Grades 7 to 9, page 22).
Level
Some experience
For classes that have used the micro:bit and MakeCode once or twice.
Board
Any micro:bit
Code with
MakeCode blocks, with Python as an extension
CAPS
Mathematics, Coding and Robotics
Fits: Grade 7, Term 4 · Where it fits

Learning intentions

Learners will learn to:

  1. Use the micro:bit's running time to measure an interval in milliseconds.
  2. Use a variable to keep track of what stage a game is in.
  3. Collect reaction times and summarise them with the mean, median and range.

Success criteria

Each learner can say:

  • I can measure an interval in milliseconds by subtracting start from the running time.
  • I can explain what each value of phase means, and why button A does something different in each.
  • I can work out the mean, the median and the range of my five times.
  • Grades 7 to 9: I can trace phase and start through two rounds, one of them too early.

Competencies

From the Coding and Robotics CAPS places this lesson cites.

  • R.7Create, test and execute a set of robotic instructions

Key words

reaction time
How long it takes you to respond to a signal.
millisecond
One thousandth of a second.
running time
How many milliseconds the micro:bit has been running.
mean
The total of the values divided by how many values there are.
median
The middle value when the values are put in order.
range
The biggest value minus the smallest.
trace table
A table that follows the value of each variable, step by step, as a program runs.

What you need

  • One micro:bit per pair, with a USB cable and a battery holder
  • A computer with Chrome or Edge for each pair
  • A results table and calculators

From our shop: BBC micro:bit V2 Go, BBC micro:bit V2.21 Next Gen Classroom Pack

Safety

  • Clear a safe space first: no bags on the floor, and enough room for everyone to move without bumping into each other.
  • Use the battery holder with two AAA batteries. Never mix old and new batteries, and take the batteries out before the kits are packed away.
  • Unplug the battery holder by holding its plug, never by pulling the wires.

The lesson plan

One lesson of 45 to 60 minutes in three parts: introduction, lesson development and consolidation. The CAPS gives Coding and Robotics 2 hours a week, so it fits one of the week's lessons. Times are a guide.

  1. Introduction

    5 to 10 minutes
    Retrieval practice

    What is a variable? (A named place in a program that holds a value, which can change while the program runs.)

    Problem statement

    October is Transport Month in South Africa, and road safety talks remind us that a driver needs time to react before the brakes are even touched. Build a reaction timer that measures, in milliseconds, how long it takes to respond to a signal.

    1. Do the ruler drop: one learner holds a 30 cm ruler, the other catches it when it falls. The lower the number, the faster the reaction.
    2. Read the problem statement together. Ask: how could a computer measure reaction time more exactly than a ruler?
  2. Lesson development

    35 to 40 minutes
    1. Unplugged first. One learner says go at a random moment while the others watch a clock's second hand and clap. Discuss why it is hard to time something so short by eye. Then act out the phase variable: one learner holds up a card with 0 (ready), 1 (waiting) or 2 (the dot is showing), and the class says what pressing A should do at each.
    2. Plan on paper first. Pairs fill in an IPO table with a row for each input and phase. Grades 7 to 9 complete the trace table for two rounds, one of them pressed too early.
    3. Predict. Ask: what will the board show if you press A before the dot appears? What if you press A when no round has started?
    4. Build in blocks. Pairs share one computer. The driver builds on button B pressed from the Blocks tab; the navigator checks each if against the IPO table and the values of phase. Swap roles halfway: the new driver builds on button A pressed and the reminder in on start.
    5. Test and debug. In the simulator, press B, wait for the dot in the middle, then press A: the number is your reaction time in milliseconds. Then press A too early, and press A with no round started. Did each match your prediction? If the time is always 0 or very small, check that start is set after the dot is plotted. Then download it.
    6. Each learner records five tries; a cross does not count. Calculate your mean and median, and the range of the class's results. Then test a question: is your other hand slower? Does it change after ten star jumps?

    Plan on paper: a model answer

    In pairs, fill in an IPO table with a row for each input and phase. Grades 7 to 9 also trace phase and start through two rounds.

    IPO table
    InputProcessingOutput
    Button B is pressed while phase is 0 (ready)Set phase to 1, clear the screen and wait a random 1 to 4 seconds. If phase is still 1, plot the dot, store the running time in start and set phase to 2A blank screen, then the dot in the middle
    Button A is pressed while phase is 2 (the dot is showing)Set phase to 0, and work out the running time minus startThe reaction time in milliseconds
    Button A is pressed while phase is 1 (waiting)Set phase to 0, so the dot will not appearA cross: too early
    Button A is pressed while phase is 0 (ready)Neither condition is true, so nothing runsNo change
    Trace table
    Grades 7 to 9: phase and start through two rounds. In round 1 the dot appears at 20 000 ms and A is pressed at 20 312 ms. In round 2, A is pressed too early.
    EventphasestartThe display shows
    Switched on00B
    B pressed10Blank, for a random wait
    The wait ends220 000The dot
    A pressed at 20 312020 000312
    B pressed again120 000Blank, for a random wait
    A pressed during the wait020 000A cross
    The wait ends020 000Still the cross: phase is not 1, so no dot
  3. Consolidation

    5 to 10 minutes
    1. Collect each learner's median on the board and find the class's fastest, slowest and range.
    2. Ask: why use the median of five tries rather than just the best one? Why does the program wait a random time before showing the dot?
    3. Back to the problem: a car at 60 km/h travels about 17 metres every second. How far would it go during the class's median reaction time, before the brakes are touched? Learners check themselves against the success criteria.

Build it, step by step

Pairs build the program in blocks, following the numbered steps, with the same program as text beside them to check against or paste. Test in the simulator before sending it to a board.

Three phases: 0 ready, 1 wait for a random 1 to 4 seconds after B is pressed, and 2 go, when the centre dot appears and the clock starts. A in phase 2 shows the time in milliseconds; A too early shows a cross.
The variable phase remembers what stage the game is in, so the same button A does different things.

These are the MakeCode steps. The other routes are on the lesson's web page.

Build it in MakeCode blocks

  1. Start a New Project and make two variables in Variables: start and phase.
  2. From Input, drag in on button B pressed. Inside, use an if from Logic: if phase = 0, set phase to 1, clear screen, then pause (ms) with pick random 1000 to 4000 from Math.
  3. Still inside, add another if: if phase = 1, plot x 2 y 2 from Led, set start to running time (ms) (under more in Input), and set phase to 2.
  4. Drag in on button A pressed with an if then else: if phase = 2, set phase to 0 and show number of running time (ms) minus start (the minus block is in Math).
  5. Use the plus sign to add else if phase = 1: set phase to 0 and show icon with the cross.
  6. In on start, add show string B as a reminder of which button starts a round.
  7. Test in the simulator, then Download.
The same blocks as text (to paste into MakeCode)
let start = 0
let phase = 0
input.onButtonPressed(Button.A, function () {
    if (phase == 2) {
        phase = 0
        basic.showNumber(input.runningTime() - start)
    } else if (phase == 1) {
        phase = 0
        basic.showIcon(IconNames.No)
    }
})
input.onButtonPressed(Button.B, function () {
    if (phase == 0) {
        phase = 1
        basic.clearScreen()
        basic.pause(randint(1000, 4000))
        if (phase == 1) {
            led.plot(2, 2)
            start = input.runningTime()
            phase = 2
        }
    }
})
basic.showString("B")

To use the text instead: open MakeCode, start a new project, click JavaScript at the top, replace what is there with this code, then click Blocks to see it as blocks.

To send it to the board, click Download. In Chrome or Edge, MakeCode can connect to the micro:bit by USB so the program goes straight onto it. Otherwise a .hex file downloads: drag it onto the MICROBIT drive.

Extension or homework

Challenges for learners who finish early, or to take further in a club or as homework.

  1. Challenge 1

    Race a partner on two boards in the Two-player reaction race.

  2. Challenge 2

    Test whether reaction times change after exercise, or at the end of the day compared with the morning.

  3. Challenge 3

    Use a sound as the signal on a micro:bit V2 instead of the dot. Are you faster with sound or with light?

Support and extension

Support

For learners who need more help

  • Give learners the B block already built, so they only build the A block.
  • Use a calculator for the mean, and find the median by ordering cards with the five times on them.

Extension

For learners who are ready for more

  • Keep the best time in a variable called best and show it when A and B are pressed together.
  • Change the program to measure B instead of A, and test whether learners are faster with their writing hand.

Informal assessment

Ask these as learners work. Informal assessment happens every day and is not recorded.

  1. What does running time (ms) measure?
  2. Why do we subtract start from the running time?
  3. Your five times were 312, 290, 455, 301 and 298 ms. What are the mean, the median and the range?
Exit question

What does the phase variable stop people from doing?

Observation checklist

Watch pairs as they plan, build and test. Write each pair's initials under the level you see.

Watch forBeginningDevelopingAccomplishedExemplary
Fills in the IPO table with a row for each input and phase.
Predicts what A does in each phase, then tests all three.
Builds the timing so that start is set after the dot is plotted.
Calculates the mean, the median and the range of five times accurately.
Beginning:
not yet, even with help
Developing:
with help
Accomplished:
on their own
Exemplary:
on their own, and explains it or takes it further

The four levels are the CAPS rubric levels (Coding and Robotics CAPS, Grades 4 to 6, page 176; Grades 7 to 9, page 163). The short descriptions are ours.

This lesson is not a formal task, but it is good practice for the term's practical task in Grades 4 to 6 (Coding and Robotics CAPS, Grades 4 to 6, page 170), and for the mini-PATs in Grades 7 to 9 (Coding and Robotics CAPS, Grades 7 to 9, page 157).

Common mistakes and fixes

  • Problem: The time is always 0 or very small.Fix: Check that start is set after the dot is plotted, and that the subtraction is running time minus start, not the other way round.
  • Problem: Pressing A does nothing.Fix: Press B first to start a round. A only works while the dot is showing (phase 2) or while waiting (phase 1).
  • Problem: The dot never appears.Fix: Check the second if checks phase = 1, and that the first block sets phase to 1 before the pause.

Where it sits in CAPS

  • Coding and RoboticsFitsGrade 7, Term 4: a micro:bit program that keeps time and score in a game. Measuring a reaction in milliseconds goes further than the CAPS example.Source: Coding and Robotics CAPS, Grades 7 to 9 (opens in a new tab), Grade 7, Term 4, Robotics, R.7 Create, test and execute a set of robotic instructions, page 86: Create a microcontroller program that can act as a timer for the game of 30-seconds and to keep score for two teams.
  • MathematicsGrades 7 and 8 Mathematics: summarising data with the mean, median and mode, and finding the range.Source: CAPS Mathematics, Grades 7 to 9 (opens in a new tab), Section 3, topic 5.1 Collect, organize and summarize data (Grade 8): Summarize data using measures of central tendency

Coding and Robotics quotes come from the Department of Basic Education's final CAPS, with the page number of the 2024 printed edition (the Department's October 2025 library copies number their pages differently). Schools may teach a topic in another term: the CAPS leaves the order to each school's annual teaching plan.

Ready to teach it?

Get a micro:bit for every learner or pair, and let us train your staff to run lessons like this one.

More lessons

All lessons →
  • Grades 6 to 9

    Grades 6 to 945 to 60 minLevel: Some experience

    Plant moisture checker

    Two crocodile clip leads and a pot plant: the micro:bit measures how damp the soil is and asks for water when it is dry.

    Subjects: Natural Sciences and Technology · Technology · Natural Sciences · Coding and Robotics

    Code with: MakeCodePurple MashPython

  • Grades 6 to 9

    Grades 6 to 945 to 60 minLevel: Confident coders

    Traffic lights

    Learners program a robot (a South African traffic light) with a pedestrian button, and plan the system as a flowchart first.

    Subjects: Natural Sciences and Technology · Technology · Coding and Robotics

    Code with: MakeCodePython

  • Grades 6 to 9

    Grades 6 to 945 to 60 minLevel: Confident coders

    Catch the drop

    A drop falls from the top, the player moves a basket with A and B: learners code a small game with sprites, coordinates and a score.

    Subjects: Coding and Robotics · Mathematics

    Code with: MakeCodePython

micro:bit is a trade mark of the Micro:bit Educational Foundation, and BBC is a trade mark of the British Broadcasting Corporation. Maze Education is an independent reseller of genuine BBC micro:bit products. Our teacher training and our other products and services are our own, and are not endorsed by the Foundation or the BBC.

WhatsApp