Closeup of a Charge for micro:bit wrapped around a child's ankle wearing crocs.

Track Your Steps with micro:bit!

Ready to get moving and see how many steps you take? This fun project uses your micro:bit to count your steps as you walk, run, or dance! It’s a simple and engaging way to explore motion sensing and data tracking with your micro:bit.

Prepare

You may complete this project with MakeCode or MicroCode. You’ll need the following materials in each case:

MakeCode

Code

Let’s take a closer look at the programs you can use to make your step-counter:

  • MakeCode
  • MicroCode

*You must click ‘Edit’ > ‘Close’ to see the code.

Understand

At a high level, these programs are doing these key things:

  1. Counting Steps: When a shake is detected by the micro:bit’s accelerometer, the step count increases by one. The step count is being tracked in a variable called steps (in MakeCode) or X (in MicroCode).
  2. Displaying the Count: After the number in the variable changes, the micro:bit displays the new number on the micro:bit’s LED screen, allowing you to see your progress.

Build

Attach the micro:bit to your wrist or ankle with CHARGE for micro:bit for a functional step counter!

Improve

How would you modify the sample code provided, or create your own code to include the following features for an even better step counter?

Try:

  • Adding a sound effect that plays after each step
  • Setting a step goal
  • Celebrating with a sound or animation when you achieve your step goal
  • Programming one of the micro:bit’s buttons to reset the count back to zero

Feeling Stuck? Explore the Knowledge Base for common questions and troubleshooting tips.