Education
Start of main content
Age Range: 11-14
Duration: 60 or more mins
  • Computing
  • D&T

Design a personal heart monitoring system with the micro:bit

Programming the micro:bit using an accelerometer and LED display

In this activity, learners will develop their programmable system using the BBC micro:bit’s inbuilt accelerometer to detect motion created by the pumping of the heart.

There are many reasons to monitor heart rate. For example:

  • There are 2.7 million people in the UK currently suffering from heart problems. The quicker these problems can be found and treated the better the chance of a full recovery.
  • Athletes measure their heart rate during training to ensure that they are training in their optimum physical range.

This BBC micro:bit accelerometer project is an ideal activity for teaching students how to integrate a programmable system into a product design. It’s one of a set of resources developed to aid the teaching of the secondary national curriculum, particularly KS3, supporting the teaching in computing and design & technology (D&T). The activity can be used as a main lesson, with Social Effects of Health Management as the starter.

Activity: Programming the micro:bit using an accelerometer and LED display


Students will use the BBC micro:bit to develop a prototype for a personal heart monitoring system. 

To create a micro:bit personal heart monitoring system, students must:

1.      Understand the brief

Using the Programming The System Health Check presentation students will review the design brief, including the importance of heart monitoring for health and fitness.

2.      Review the system diagram

Students will review the presentation, which shows a block diagram of a heart monitoring system. Students can use this systems diagram as an example of how they can plan out their own health monitoring system.

3.      Follow the design criteria

Students will review design criteria, which explains that the system must:

  • Integrate the BBC micro:bit
  • Use the micro:bit’s inbuilt accelerometer.
  • Have an LED display to show the heart rate.
  • Use either a buzzer or a beeper as a sound output.

4.      Use an accelerometer

The accelerometer must be used as the input device for the micro:bit to detect subtle movements caused by a beating heart.

5.      Choose output device

Students can connect either a buzzer or a beeper to their micro:bit, which will give an audible indication of a person’s heart rate. They will also use an LED display to show heart rate information.

6.      Code the Program

Students will then write their programme, using the either the JavaScript Blocks Editor or Python Editor. The programming should focus on the key tasks of reading data from the accelerometer, processing that data to calculate an approximate heart rate, displaying the heart rate on the LED screen, and optionally activating the buzzer/beeper in sync with the person’s heart rate.

Example programs can be used as guides where necessary (see below).

7.      Download and test their programme

Students will download their programme onto the micro:bit and make adjustments and improvements (if necessary).

Where can I find the example programme for making a personal heart monitoring system with the micro:bit?

The instructions for where you can find and download the example programmes for the JavaScript Blocks Editor and Python Editor are below:

Example accelerometer program – JavaScript Blocks Editor

  1. Go to www.microbit.org/code and open the JavaScript Blocks Editor.
  2. Drag the file microbit-heartrate-jsb.hex onto the work area.
  3. Button A can also be used to test if it is working.
  4. Test it, download it and experiment with how it works!

Example accelerometer program – Python Editor

  1. Go to www.microbit.org/code and open the Python Editor.
  2. Drag the file heartrate.py onto the work area.
  3. Button A can also be used to test if it is working.
  4. Test it, download it and experiment with how it works!

What does an accelerometer do on a BBC micro:bit?

An accelerometer is a motion sensor that measures changes in movement along different axes. It can detect if something is speeding up, slowing down, or even changing direction.

On the BBC micro:bit, the accelerometer's sensitivity allows it to pick up the tiny vibrations caused by a heartbeat. By programming the micro:bit to analyse those vibrations, you can create a simple prototype heart rate monitor as when the accelerometer detects movement the LED screen will create a graphical representation of the heartbeat. A buzzer or beeper can also be added for the beats.

The engineering context

Engineers use accelerometers in a wide variety of devices, including smartphones (for screen rotation and step tracking), drones (for stabilisation), and fitness/medical devices (for monitoring movement and heart activity). By learning to program an accelerometer with the BBC micro:bit, students will develop coding skills relevant to fields like robotics, biomedical engineering, and product design.

Suggested learning outcomes

Students will understand how to read a block systems diagram (specifically for a heart monitoring device). They’ll also be able to understand how accelerometer can be used as a heart monitoring device. Finally, they’ll be able to programme the BBC micro:bit so that their system meets the design criteria.

Download our activity sheet and other teaching resources

The activity sheet includes teachers’ notes, useful web links, and links (where appropriate) to the national curriculum in each of the four devolved nations; England, Northern Ireland, Scotland and Wales.

All activity sheets and supporting resources are free to download, and all the documents are fully editable, so you can tailor them to your students’ and your schools’ needs.

Download our classroom lesson plan and presentation below.

Please do share your highlights with us @IETeducation. 

Videos

Heart rate monitor

Exploring how the accelerometer function within the BBC micro:bit can be used to measure your heart rate.

Related resources