Code Your Micro:bit to Measure your Activity

Use code and the micro:bit’s accelerometer to create a device that can count the number of steps taken when the micro:bit moves.

Step 1

Create a new blank project in the JavaScript Blocks Editor.

Step 2

The micro:bit has a built-in accelerometer that's great for detecting movement. Create a code to record the number of steps taken. 

Here are some tips:

  • Use a variable to store the number of steps taken so far
  • Update that number when the micro:bit moves
  • Display the current number of steps taken on the screen

Step 3

Hint – here’s one way you might do it: