Lesson at a glance
maze.education/microbit/lessons/fitness-challenge
- Grades
- Grades 4 to 7
- Time
- 45 to 60 minutesThe 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 experienceFor 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
- Life Skills, Life Orientation, Coding and Robotics, MathematicsFits: Grade 7, Term 4 · Where it fits
Learning intentions
Learners will learn to:
- Use the accelerometer's strength reading and a threshold to detect a jump.
- Use a variable as a counter and a timer to end the challenge.
- Set a personal fitness goal and compare two tries fairly.
Success criteria
Each learner can say:
- I can explain how the threshold of 2000 turns a landing into one counted jump.
- I can use a variable to count jumps and a timer to stop counting after 30 seconds.
- I can set a personal goal and compare my two tries by working out the difference.
- Grade 7: I can trace counting and jumps as the readings change, and explain why both conditions must be true.
Competencies
From the Coding and Robotics CAPS places this lesson cites.
- R.3Outline the different components of a robot
- R.7Create, test and execute a set of robotic instructions
Key words
- accelerometer
- The sensor that measures movement and forces in three directions.
- strength
- The size of the whole movement, in milli-g. Standing still it reads about 1023: that is gravity, 1 g.
- threshold
- The value a reading must pass to count, here 2000.
- counter
- A variable that goes up by one each time something happens.
- personal best
- Your own best result, to beat next time.
- 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 learner or pair, with a battery holder
- A strap to fix the micro:bit and battery holder to the wrist (the classroom pack includes straps and holders)
- A computer with Chrome or Edge for each pair, and space to move: the hall, the field or a cleared classroom
From our shop: BBC micro:bit V2.21 Next Gen Classroom Pack, micro:bit Battery Box (Switched)
Safety
- Clear a safe space first: no bags on the floor, and enough room for everyone to move without bumping into each other.
- Warm up first and cool down after. Anyone who feels unwell stops and sits down, and anyone can choose a gentler movement.
- Strap the micro:bit and battery holder firmly to the wrist so nothing can fly off.
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.
Introduction
5 to 10 minutesRetrieval practiceWhat does a variable do in a program? (It holds a value, such as a score, that can change while the program runs.)
Problem statementIn Physical Education it is hard to count your own star jumps, and a partner's count can be generous or strict. Program the micro:bit to count jumps for 30 seconds, check it against a partner's tally, and use it to set and beat a personal goal.
- Warm up together for three minutes: march on the spot, arm circles, gentle stretches.
- Read the problem statement. Ask: how could a micro:bit tell that you jumped? Feel the jolt when you land: that is what the accelerometer measures.
Lesson development
35 to 40 minutes- Unplugged first. In pairs, one learner does star jumps for 30 seconds while the other counts with tally marks. Swap. Keep the counts to compare with the micro:bit later. Did anyone lose count?
- Plan on paper first. Pairs write the algorithm and fill in the IPO table. Grade 7 learners add the trace table: counting, the strength reading and jumps at a few moments in the challenge.
- Predict. Ask: what will the micro:bit show if you stand still for the whole 30 seconds? Will it count more jumps than your partner's tally, or fewer? Pairs write their predictions down.
- Build in blocks. Pairs share one computer. The driver builds the countdown and the 30-second timer from the Blocks tab; the navigator checks each block against the algorithm. Swap roles halfway, after step 3, so the new driver builds the jump counter in forever, with its and.
- Test and debug. Test the countdown in the simulator: press A and check for 3, 2, 1, the tick, and a number after 30 seconds. Then download it, strap the micro:bit to a wrist and do the challenge. Compare with your partner's tally and your prediction: if the micro:bit counts too many or too few, try a threshold of 1800 or 2300.
- Rest, set a goal, and try again. Record both results and the difference.
Plan on paper: a model answer
In pairs, write the challenge's algorithm and fill in the IPO table. Grade 7 learners also trace counting and jumps as the readings change.
Algorithm
- Wait for button A.
- Set jumps to 0 and count down 3, 2, 1.
- Show a tick and set counting to true.
- For 30 seconds: whenever counting is true and the strength is over 2000, add 1 to jumps and wait 300 milliseconds.
- Set counting to false and show jumps.
IPO table
Input Processing Output Button A is pressed Set jumps to 0, count down, then set counting to true for 30 seconds 3, 2, 1, then a tick A strength reading over 2000 while counting is true Add 1 to jumps, then wait 300 milliseconds so one landing counts once Nothing new: the count is kept in jumps The 30 seconds are up Set counting to false The number of jumps Trace table
Grade 7: what the forever loop finds at a few moments. The strength readings are examples. Moment counting strength (mg) jumps Before A is pressed false 1023 0 After the tick, standing still true 1030 0 First landing true 2400 1 In the air true 600 1 Second landing true 2600 2 A landing after the 30 seconds false 2500 2, shown on the display Consolidation
5 to 10 minutes- Cool down: walk slowly and stretch.
- Ask: what does the threshold do? What happened when you changed it?
- Back to the problem: was the micro:bit's count fairer than a partner's tally? Why do we compare your two tries with each other, rather than with someone else's? 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.
These are the MakeCode steps. The other routes are on the lesson's web page.
Build it in MakeCode blocks
- Start a New Project and make two variables in Variables: jumps and counting.
- From Input, add on button A pressed. Inside: set jumps to 0, then a for index from 0 to 2 loop from Loops with show number of 3 minus index (minus is in Math) and pause (ms) 500.
- Still inside: show icon tick, set counting to true, pause (ms) 30000, set counting to false, then show number jumps.
- In forever, add an if with an and block from Logic: counting, and acceleration (mg) strength (from Input) > 2000.
- Inside the if: change jumps by 1 and pause (ms) 300, so one landing counts once.
- Test in the simulator, then Download.
let jumps = 0
let counting = false
input.onButtonPressed(Button.A, function () {
jumps = 0
for (let index = 0; index <= 2; index++) {
basic.showNumber(3 - index)
basic.pause(500)
}
basic.showIcon(IconNames.Yes)
counting = true
basic.pause(30000)
counting = false
basic.showNumber(jumps)
})
basic.forever(function () {
if (counting && input.acceleration(Dimension.Strength) > 2000) {
jumps += 1
basic.pause(300)
}
})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.
No Purple Mash route for this lesson
We could not find a Purple Mash unit or project that matches this lesson, so it is MakeCode blocks, with Python as an extension. These lessons have a Purple Mash route:
Extension: text-based coding, beyond the CAPS
The same program in MicroPython, for the micro:bit Python Editor. It suits Grade 7 to 9 learners who are ready for text-based code. The CAPS itself follows a block-based approach (Coding and Robotics CAPS, Grades 7 to 9, page 24).
# 30-second fitness challenge: press A, count down, then jump. The count shows after 30 seconds.
from microbit import *
import math
while True:
if button_a.was_pressed():
for n in (3, 2, 1):
display.show(n)
sleep(500)
display.show(Image.YES)
jumps = 0
end = running_time() + 30000
while running_time() < end:
x, y, z = accelerometer.get_values()
if math.sqrt(x * x + y * y + z * z) > 2000:
jumps = jumps + 1
sleep(300)
sleep(10)
display.scroll(jumps)
sleep(50)The Python version works out the strength of the movement itself with Pythagoras: the square root of x squared plus y squared plus z squared. A good puzzle for older learners.
Open the Python editor, replace the code that is there with this program (or open the downloaded file), then click Send to micro:bit. MakeCode also has a Python view, which is written a little differently.
Extension or homework
Challenges for learners who finish early, or to take further in a club or as homework.
- Challenge 1
Run a class challenge: record everyone's score in a table and find the mean, the median and the range.
- Challenge 2
Change the exercise to squats or step-ups. Does the micro:bit count them as well as star jumps? Why or why not?
- Challenge 3
Add a ten-second rest timer that beeps on a micro:bit V2 when it is time for the next round.
Support and extension
Support
For learners who need more help
- Let learners choose a movement they can do safely: star jumps, step-ups or arm pumps all register as movement.
- Use a shorter challenge of 15 seconds: change 30000 to 15000.
Extension
For learners who are ready for more
- Keep a personal best in a variable and show a trophy you draw with show leds when it is beaten.
- Work out jumps per minute from your 30-second result, and compare morning and afternoon tries.
Informal assessment
Ask these as learners work. Informal assessment happens every day and is not recorded.
- Why is there a short pause after each counted jump?
- Your two tries were 24 and 31 jumps. What is the difference?
- About what reading does the micro:bit give when you stand still, and why?
What does the threshold of 2000 mean, and what would happen if it were 1100?
Observation checklist
Watch pairs as they plan, build and test. Write each pair's initials under the level you see.
| Watch for | Beginning | Developing | Accomplished | Exemplary |
|---|---|---|---|---|
| Warms up first, and chooses a movement that is safe for them. | ||||
| Explains the threshold in their own words. | ||||
| Compares the micro:bit's count with a partner's tally, and adjusts the threshold. | ||||
| Records two tries and works out the difference. |
- 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
- It counts before I start jumping.The countdown block may be missing set counting to true after it, or the threshold is too low. Try 2200.
- It counts far too few jumps.Strap it on firmly and land with a bit of a bounce, or lower the threshold to 1800.
- The count never shows.Wait the full 30 seconds after the tick. Check the pause (ms) says 30000, not 300000.
Where it sits in CAPS
- Coding and RoboticsFitsGrade 7, Term 4: a micro:bit timer for a 30-second game that keeps score.Source: Coding and Robotics CAPS, Grades 7 to 9, 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.
- Coding and RoboticsFitsGrade 7, Term 2: a sensor as an input that triggers an action, here a jump.Source: Coding and Robotics CAPS, Grades 7 to 9, Grade 7, Term 2, Robotics, R.3 Outline the different components of a robot, page 70:
Outline the basic purpose of a sensor as an input mechanism, which could be processed to trigger an action.
- Life SkillsGrade 6 Physical Education: taking part in a fitness programme, with warm-up and safety.Source: CAPS Life Skills, Grades 4 to 6, Grade 6, Term 2, Physical Education:
Participation in a physical fitness programme to develop particular aspects of fitness
- MathematicsFits Mathematics: comparing two results and working out the difference.
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.
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.

