micro:bit Projects for Kids: Build a Step Counter This Weekend
One of the best micro:bit projects for kids is a homemade step counter: a few lines of Python turn the board's built-in accelerometer into a pedometer that counts every step, shows the total when you press a button, and resets with another. It takes about an hour, needs no extra parts beyond a battery pack, and teaches real ideas engineers use every day: sensors, thresholds and filtering noisy data.
Here is the full project, with tested code, so your child can build it this weekend.
What you need
A BBC micro:bit (V1 or V2 both work)
A USB cable to load the code
A battery pack (2×AAA) so it can go in a pocket or be strapped to a shoe
The free online Python editor at python.microbit.org (no install needed)
Optional: tape, a sock or a velcro strap to hold the micro:bit in place
Don't have a micro:bit yet? Our coaches compare starter boards in Best Robotics Kits for Kids at Home.
How a step counter works
The micro:bit has an accelerometer, a tiny sensor that measures how hard the board is being pushed in three directions (x, y and z). Even sitting still on a desk it reads about 1,000 milli-g, because gravity is always pulling on it.
When you walk, every footstep gives the board a little jolt. If we combine the three directions into one number, the strength, it jumps above normal each time your foot hits the ground. So the plan is simple:
Read the accelerometer about 50 times a second.
Work out the total strength: the square root of x² + y² + z².
When strength goes above a HIGH line, count one step.
Wait until it drops back below a LOW line before counting again.
That last step is the clever part. Without it, one wobbly footstep might cross the line three or four times and count as several steps. Using two lines (engineers call it hysteresis) makes the counter ignore that jitter.
The code (MicroPython)
Open python.microbit.org, delete the starter code, and paste this in:
from microbit import *
import math
steps = 0
HIGH = 1500 # milli-g: a step's "bump" goes above this
LOW = 1150 # must drop back below this before we count again
stepping = False
display.show(Image.HEART)
while True:
x, y, z = accelerometer.get_values()
strength = math.sqrt(x * x + y * y + z * z)
if not stepping and strength > HIGH:
steps += 1
stepping = True
elif stepping and strength < LOW:
stepping = False
if button_a.was_pressed():
display.scroll(steps)
if button_b.was_pressed():
steps = 0
display.show(Image.YES)
sleep(500)
display.show(Image.HEART)
sleep(20)Click Send to micro:bit, unplug the USB cable, connect the battery pack and go for a walk. Press A to scroll your step count and B to reset it to zero.
Assumptions: readings are in milli-g (about 1,000 at rest). We tested the counting logic in a simulator with fake walking data (20 simulated steps counted as 20), so you may need to tune the two numbers for your own stride and where you wear the board.
Make it accurate: tuning tips
Counting too many steps? Raise HIGH to 1600 or 1700.
Missing steps? Lower HIGH to 1400. Keep LOW at least 250 below HIGH.
Where you wear it matters. A shoe or ankle gives the clearest bumps; a loose pocket gives the messiest.
Test like a scientist. Walk exactly 50 steps, check the count, change one number, and try again. Write the results down.
That last tip is the real lesson. Kids quickly see that sensors are never perfect, and that good engineers measure, adjust and measure again.
Level it up
Once the basic counter works, try one of these challenges:
Show a smiley face when you reach a goal, like 1,000 steps.
Light up one more LED for every 100 steps so you can see progress without pressing a button.
Use the micro:bit radio to send your steps to a friend's micro:bit and race each other.
Turn it into a jump counter for jumping jacks or a jump rope by changing the thresholds.
If your child enjoyed this, our light-up Halloween pumpkin with micro:bit uses the same accelerometer in a spooky way, and mBot2 vs micro:bit vs LEGO CS & AI helps you pick what to build next.
Common questions
What age is this project for?
Kids around 9 and up can type and tune the Python version with a little help. Younger kids can build the same idea in MakeCode blocks using an "on shake" event that adds 1 to a variable.
Does it work on the micro:bit V1?
Yes. The code uses only the accelerometer, buttons and display, which every micro:bit has.
Is it as accurate as a fitness watch?
Not quite, but with a bit of tuning it gets close on a normal walk. Figuring out why it miscounts is the most valuable part of the project.
Keep learning with Fusion Robotics Education
Want more projects like this? Our micro:bit Robotics Explorers course starts from the basics, and Advanced micro:bit goes further with radio, sensors and robots. You can start with our free self-paced courses, unlock nearly the whole catalog with All-Access ($39/month, 7-day free trial), or get a live coach with Remote 1-on-1 lessons ($149/month, text (619) 786-5731).
In San Diego? Join our weekend group sessions in Scripps Ranch: 1.5 hours a week, ages 6–18, max 10 kids, and every child works on their own project at their own pace. Your first session is free. Text (619) 786-5731 to book.



Comments