The Activity Tracker Project using the BBC Micro:bit. It records time spent walking, jumping, rolling, and being still using the Micro:bit’s sensors. I built it to track different movements in a fun and easy way
def on_stop_detailed(duration):
global jumpingtime
basic.clear_screen()
jumpingtime += duration
ml.on_stop_detailed(ml.event.jumping, on_stop_detailed)
def on_stop_detailed2(duration2):
global stilltime
basic.clear_screen()
stilltime += duration2
ml.on_stop_detailed(ml.event.being_still, on_stop_detailed2)
def on_stop_detailed3(duration3):
global walkingtime
basic.clear_screen()
walkingtime += duration3
ml.on_stop_detailed(ml.event.walking, on_stop_detailed3)
def on_button_pressed_a():
basic.show_number(walkingtime / 1000)
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_on_start():
basic.show_leds("""
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
""")
music.play(music.string_playable("A D G F D E C5 C ", 120),
music.PlaybackMode.UNTIL_DONE)
ml.on_start(ml.event.running, on_on_start)
def on_on_start2():
basic.show_leds("""
. . # . .
. . # . .
. . # . .
. . # . .
# # # # #
""")
ml.on_start(ml.event.walking, on_on_start2)
def on_on_start3():
basic.show_number(67)
music.play(music.string_playable("B A G A G F A C5 ", 120),
music.PlaybackMode.UNTIL_DONE)
ml.on_start(ml.event.jumping, on_on_start3)
def on_button_pressed_ab():
basic.show_number(stilltime / 1000)
input.on_button_pressed(Button.AB, on_button_pressed_ab)
def on_button_pressed_b():
basic.show_number(jumpingtime / 1000)
input.on_button_pressed(Button.B, on_button_pressed_b)
def on_on_start4():
basic.show_leds("""
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
""")
ml.on_start(ml.event.rolling, on_on_start4)
def on_on_start5():
basic.show_icon(IconNames.HEART)
ml.on_start(ml.event.being_still, on_on_start5)
stilltime = 0
jumpingtime = 0
walkingtime = 0
walkingtime = 0
jumpingtime = 0
stilltime = 0
The Activity Tracker Project is designed to monitor and record different types of human movement using the BBC Micro:bit. The micro:bit is a small, programmable device equipped with sensors like an accelerometer, which can detect motion in multiple directions. This project focuses on tracking four main activities: walking, jumping, rolling, and being still. The goal is to make movement tracking simple, interactive, and engaging, allowing users to see how much time they spend performing each activity.
This project can be used in educational settings to demonstrate how sensors and machine learning can be applied in real life, or for fun personal tracking to encourage physical activity. The micro:bit provides real-time feedback through LED displays and sounds, making it easier to understand which activity is being recorded at any moment.
The model behind this project uses micro:bit’s machine learning (ML) extension, which can detect patterns in motion and classify them into different events. Each movement — walking, jumping, rolling, and being still — generates a unique pattern of accelerometer readings. The ML extension identifies these patterns and triggers an event when a specific activity starts or stops.
The model works in an event-driven manner, meaning it doesn’t constantly record data but responds to activity changes. When an activity begins, the micro:bit gives visual or audio feedback, so the user knows which activity is being tracked. When the activity ends, the model calculates the duration of the movement and adds it to a total counter for that specific activity. Over time, the micro:bit accumulates the total time spent in each type of movement.
Creating this project involved several steps:
Sensor Setup: The micro:bit’s accelerometer was configured to detect different types of motion. This sensor is crucial because it can sense tilting, shaking, and sudden movements.
Event Detection: Using the ML extension, the micro:bit was trained or set to detect when a user starts walking, jumping, rolling, or stops moving. Each activity has its unique event trigger.
Tracking Activity Duration: For each event, the micro:bit calculates the time the activity lasts. This duration is added to a variable that keeps a running total, allowing the user to see cumulative activity times.
User Interaction and Feedback: To make the tracker interactive, the micro:bit provides feedback when an activity starts. This is done using LED patterns or simple musical tones, which indicate which movement is being tracked. Users can press buttons on the micro:bit to display the total time spent walking, jumping, or being still.
Portability and Ease of Use: The micro:bit can be used while walking or exercising, and the tracker works in real time. This makes it a practical and portable solution for activity tracking.
The micro:bit constantly monitors the user’s movements through its accelerometer. When the user starts moving, the ML model detects the type of activity and triggers a start event, giving feedback through LEDs or sounds. Once the activity ends, a stop event is triggered, and the micro:bit calculates how long the activity lasted. This duration is added to the corresponding total for that activity.
At any time, users can check the total time spent on each activity by pressing buttons. For example, one button may show walking time, another may show jumping time, and a combination of buttons may show still time. This approach allows the tracker to collect data efficiently, provide immediate feedback, and display results in a user-friendly manner. Overall the project displays the ways in which micro:bit can be used in order to help in the real world and in our everyday life such as calculating the activities we perform and many more.