Fall alarm

The accelerometer senses a fall, or the wearer presses a panic button, and an alarm goes off on a carer's board across the room.

Go to the code ↓

Lesson at a glance

45 to 60 minutes · Grades 7 to 9

maze.education/microbit/lessons/fall-alarm

Grades
Grades 7 to 9
Time
45 to 60 minutes
The CAPS gives Coding and Robotics 2 hours a week (Coding and Robotics CAPS, Grades 7 to 9, page 22).
Level
Confident coders
For confident classes: more steps to build, with variables, radio or data.
Board
Any micro:bit
Code with
MakeCode blocks, with Python as an extension
CAPS
Technology, Coding and Robotics, Natural Sciences
Fits: Grade 9, Term 2 · Where it fits

Learning intentions

Learners will learn to:

  1. Use the accelerometer's free fall gesture as an input.
  2. Design an alarm with OR logic: a fall OR a panic button sets it off.
  3. Send an alert by radio to a second board, and judge the system's strengths and weaknesses.

Success criteria

Each learner can say:

  • I can use the free fall gesture as an input that sets off the alarm.
  • I can complete the truth table for an OR alarm and point to the OR in my program.
  • I can send an alert by radio to a second board, and test the system for false alarms.
  • I can name a strength and a weakness of our alarm, with evidence from our tests.
  • I can trace alarm and the radio messages through a test run.

Competencies

From the Coding and Robotics CAPS places this lesson cites.

  • R.3Outline the different components of a robot
  • R.5Design a simple artefact based on a set of design instructions
  • R.6Mimic the operations of a robot
  • D.7Present a basic understanding of the concept of input processing and output

Key words

accelerometer
A sensor that measures movement and tilt. The micro:bit uses it to recognise gestures.
free fall
Falling with nothing holding you up. The accelerometer reads close to zero force.
OR logic
The output is on if one input OR the other OR both are on.
panic button
A button someone presses to call for help.
false alarm
An alarm that goes off when nothing is wrong.
truth table
A table that shows the output for every combination of inputs.
trace table
A table that follows the value of each variable, step by step, as a program runs.

What you need

  • Two micro:bits for each pair, with USB cables and battery holders
  • A computer with Chrome or Edge for each pair
  • A cushion, a pillow or a soft bag on the floor for each pair, for drop tests from no higher than a desk

From our shop: BBC micro:bit V2 Club Pack, BBC micro:bit V2.21 Next Gen Classroom Pack

Safety

  • Drop the micro:bit only onto a cushion or a soft bag, from no higher than a desk. Never throw it, and never drop it with the USB cable attached.
  • Keep the battery holder taped or held to the board for drop tests, so it cannot swing and pull on the wires.
  • Keep the volume low and the micro:bit away from ears. Someone may be sensitive to sudden sounds, so warn the class before the first sound plays.

The lesson plan

One lesson of 45 to 60 minutes in three parts: introduction, lesson development and consolidation. The CAPS gives Coding and Robotics 2 hours a week, so it fits one of the week's lessons. Times are a guide.

  1. Introduction

    5 to 10 minutes
    Retrieval practice

    How do two micro:bits hear each other's radio messages and nobody else's? (Both use the same radio group number, and other pairs use different ones.)

    Problem statement

    A gogo who is home alone while the family is at work or school may lie for hours after a fall before anyone knows. Design a prototype alarm that senses a fall or a panic button and alerts a carer's board across the room by radio, then test how far you would trust it.

    1. Ask: who in a community might need an alarm if they fell when nobody was home? Think of older people living alone and people with some medical conditions. Show a picture of a personal alarm pendant or a smartwatch with fall detection: what does it sense, and who does it tell?
    2. Read the problem statement. Explain that the class will build a prototype: a first version to test and learn from, not a product to trust with someone's safety.
  2. Lesson development

    35 to 40 minutes
    1. Unplugged first. Draw the truth table for the alarm: two inputs, fall and panic button, each yes or no, and the output alarm. Fill in all four rows. Which row is a false alarm risk? Which row matters most?
    2. Plan on paper first. Give each pair a radio group number from 0 to 255. Pairs write the algorithm and fill in the IPO table, with a row for each input on either board. Then they complete the trace table for a test run.
    3. Predict. Ask: when the wearer's board falls onto the cushion, what will each board show? What happens if the wearer then presses B? What would an AND alarm do instead? Pairs write their predictions beside the trace table.
    4. Build in blocks. Pairs share one computer. The driver builds the alarm from the Blocks tab, with the pair's group number instead of 9; the navigator checks each block against the IPO table. Swap roles halfway, after step 4, so the new driver builds on radio received and the alarm loop. Download it to both boards: every board can be the wearer or the carer.
    5. Test and debug. Test the panic button first: A and B together start the alarm on the wearer's board and send HELP to the carer's board, and B stops it. Then test the fall: hold the board over the cushion, no higher than a desk, and let go. Compare each result with the trace table and fix the first place they differ.
    6. Test for false alarms: walk, sit down hard, jump, wave the board. Does anything set it off? Record every test in a table: what you did, what happened and whether it was a false alarm.

    Plan on paper: a model answer

    In pairs, write the alarm's algorithm and fill in the IPO table for both boards, then complete the trace table for a test run.

    Algorithm
    1. Set the radio group to the pair's number, and set alarm to false.
    2. If a free fall is sensed, set alarm to true and send FALL by radio.
    3. If A and B are pressed together, set alarm to true and send HELP by radio.
    4. If B is pressed, set alarm to false and clear the screen.
    5. If a message arrives, scroll it and play ba ding.
    6. Over and over: if alarm is true, flash the cross and beep.
    IPO table
    InputProcessingOutput
    A free fall, sensed by the accelerometerSet alarm to true and send FALL by radioThe wearer's board flashes a cross and beeps
    A and B pressed together (the panic button)Set alarm to true and send HELP by radioThe wearer's board flashes a cross and beeps
    Button B is pressedSet alarm to false and clear the screenThe flashing and beeping stop
    A message arrives by radioKeep it in receivedString and play ba ding in the backgroundFALL or HELP scrolls on the carer's board, with a ba ding
    Trace table
    A test run, with the wearer's board (W) and the carer's board (C) in the pair's radio group.
    Eventalarm on WSent by radioW showsC shows
    StartfalseNothingNothingNothing
    The wearer walks and sits downfalseNothingNothingNothing
    W falls onto the cushiontrueFALLA flashing cross, with beepsFALL, with a ba ding
    B pressed on WfalseNothingNothingNothing new
    A and B pressed together on WtrueHELPA flashing cross, with beepsHELP, with a ba ding
    B pressed on WfalseNothingNothingNothing new
  3. Consolidation

    5 to 10 minutes
    1. Ask: where is the OR in our program? What would an AND alarm do differently, and why would it be dangerous here?
    2. Ask: what are the weaknesses of our system? (The radio's range, flat batteries, a fall onto the floor that is not a free fall.)
    3. Back to the problem: would you trust this prototype to look after a gogo at home alone? What should a real product do after a false alarm, and who should be told? Learners check themselves against the success criteria.

Build it, step by step

Pairs build the program in blocks, following the numbered steps, with the same program as text beside them to check against or paste. Test in the simulator before sending it to a board.

A free fall OR the A and B panic button sets off the alarm: the wearer's board flashes a cross and beeps at 880 Hz until B is pressed, and sends FALL or HELP by radio in group 9 for the carer's board to scroll.
OR logic: either input, a fall or the panic button, sets off the same alarm, and the radio message tells the carer which one happened.

These are the MakeCode steps. The other routes are on the lesson's web page.

Build it in MakeCode blocks

  1. Start a New Project called Fall alarm. Put radio set group 9 in on start, with your pair's number. In Variables, make alarm.
  2. From Input, add on shake and change shake to free fall. Inside: set alarm to true and radio send string "FALL".
  3. Add on button A+B pressed: set alarm to true and radio send string "HELP". This is the panic button.
  4. Add on button B pressed: set alarm to false and clear screen.
  5. From Radio, add on radio received receivedString: show string receivedString and play melody ba ding in the background.
  6. In forever, add if alarm then: show icon with the cross, play tone 880 Hz for 1/4 beat until done, clear screen and pause (ms) 200.
  7. Test the panic button in the simulator (it shows two boards). The simulator cannot drop a board, so test the fall on real micro:bits after you Download to both.
The same blocks as text (to paste into MakeCode)
let alarm = false
input.onGesture(Gesture.FreeFall, function () {
    alarm = true
    radio.sendString("FALL")
})
input.onButtonPressed(Button.AB, function () {
    alarm = true
    radio.sendString("HELP")
})
input.onButtonPressed(Button.B, function () {
    alarm = false
    basic.clearScreen()
})
radio.onReceivedString(function (receivedString) {
    basic.showString(receivedString)
    music.play(music.builtInPlayableMelody(Melodies.BaDing), music.PlaybackMode.InBackground)
})
radio.setGroup(9)
basic.forever(function () {
    if (alarm) {
        basic.showIcon(IconNames.No)
        music.play(music.tonePlayable(880, music.beat(BeatFraction.Quarter)), music.PlaybackMode.UntilDone)
        basic.clearScreen()
        basic.pause(200)
    }
})

To use the text instead: open MakeCode, start a new project, click JavaScript at the top, replace what is there with this code, then click Blocks to see it as blocks.

To send it to the board, click Download. In Chrome or Edge, MakeCode can connect to the micro:bit by USB so the program goes straight onto it. Otherwise a .hex file downloads: drag it onto the MICROBIT drive.

Extension or homework

Challenges for learners who finish early, or to take further in a club or as homework.

  1. Challenge 1

    Write a design brief for a real fall alarm: who it is for, where it is worn, how long the batteries must last and who it should alert.

  2. Challenge 2

    Draw the system as a block diagram: inputs, process, outputs and the radio link between the two boards.

  3. Challenge 3

    Measure the radio's range: how far apart can the boards be, and through how many walls, before the message stops arriving?

Support and extension

Support

For learners who need more help

  • Build the panic button and the radio message first; add the free fall once those work.
  • Give pairs the truth table half filled in, and the finished program with only the radio group to change.

Extension

For learners who are ready for more

  • Cut false alarms: after a free fall, wait two seconds and only send FALL if the board is now still (use acceleration (mg) strength).
  • Add a repeat: the wearer's board sends the message every five seconds until a carer presses A on their board to say help is coming, and that reply stops it.

Informal assessment

Ask these as learners work. Informal assessment happens every day and is not recorded.

  1. Name the two inputs that can start the alarm, and the logic that joins them.
  2. Fill in the truth table: no fall and no button gives what? A fall and no button gives what?
  3. What is a false alarm, and what in your tests caused one?
Exit question

Give one reason our system would not be good enough for a real person yet.

Observation checklist

Watch pairs as they plan, build and test. Write each pair's initials under the level you see.

Watch forBeginningDevelopingAccomplishedExemplary
Completes all four rows of the truth table, and says which row matters most.
Tests the panic button and the fall separately, and records each result.
Compares the results with the trace table and fixes the first difference.
Judges the system's weaknesses with evidence from the tests.
Beginning:
not yet, even with help
Developing:
with help
Accomplished:
on their own
Exemplary:
on their own, and explains it or takes it further

The four levels are the CAPS rubric levels (Coding and Robotics CAPS, Grades 7 to 9, page 163). The short descriptions are ours.

This lesson is not a formal task, but it is good practice for the mini-PATs in Grades 7 to 9 (Coding and Robotics CAPS, Grades 7 to 9, page 157).

Common mistakes and fixes

  • Problem: The fall does not set off the alarm.Fix: Let the board fall freely, without throwing it or holding the cable. The drop must be long enough to sense: from desk height onto a cushion works.
  • Problem: The alarm stops as soon as the panic button is pressed.Fix: Press A and B at exactly the same moment. In Python, keep the lines that clear the button presses after HELP is sent.
  • Problem: The carer's board shows nothing.Fix: Check both boards share a radio group and have the new program. Test with the boards a few metres apart first: walls, doors and people shorten the radio's range indoors.

Where it sits in CAPS

  • Coding and RoboticsFitsGrade 9, Term 2: use the micro:bit's accelerometer as an input.Source: Coding and Robotics CAPS, Grades 7 to 9 (opens in a new tab), Grade 9, Term 2, Digital Concepts, D.7 Present a basic understanding of the concept of input processing and output, page 145: Using the accelerometer to obtain readings
  • Coding and RoboticsFitsGrade 9, Term 2: AND, OR and NOT logic in a system with sensors, with a truth table.Source: Coding and Robotics CAPS, Grades 7 to 9 (opens in a new tab), Grade 9, Term 2, Robotics, R.5 Design a simple artefact based on a set of design instructions, with R.6, page 140: Logical gates (AND, OR and NOT) and how it relates to the design, programming, and functioning of robotic systems.
  • Coding and RoboticsFitsGrade 7, Term 3: sending a message from one micro:bit to another by radio, here the alert.Source: Coding and Robotics CAPS, Grades 7 to 9 (opens in a new tab), Grade 7, Term 3, Robotics, R.3 Outline the different components of a robot, page 79: The learners are introduced to the concept of message passing between two devices.
  • TechnologyGrade 8 Technology: OR logic and where it is used, in the term that designs a panic button system.Source: CAPS Technology, Grades 7 to 9 (opens in a new tab), Grade 8, Term 4: Electrical systems and control (Mini-PAT, logic gates): Investigation: OR logic gate and simple cases where it is used.
  • Natural SciencesFits Natural Sciences: forces and motion, and what happens to the forces we feel when something falls freely.

Coding and Robotics quotes come from the Department of Basic Education's final CAPS, with the page number of the 2024 printed edition (the Department's October 2025 library copies number their pages differently). Schools may teach a topic in another term: the CAPS leaves the order to each school's annual teaching plan.

Ready to teach it?

Get a micro:bit for every learner or pair, and let us train your staff to run lessons like this one.

More lessons

All lessons →
  • Grades 7 to 9

    Grades 7 to 945 to 60 minLevel: Some experience

    Radio messages

    Boards in the same radio group send YES and NO across the room: learners build a wireless system and explore groups.

    Subjects: Technology · Coding and Robotics

    Code with: MakeCodePython

  • Grades 7 to 9Needs a micro:bit V2

    Grades 7 to 9Needs a micro:bit V245 to 60 minLevel: Confident coders

    Data logger

    The micro:bit V2 records temperature, light and sound every ten seconds; learners open the data as a table, graph it and explain the pattern.

    Subjects: Mathematics · Natural Sciences · Coding and Robotics

    Code with: MakeCodePython

  • Grades 6 to 9

    Grades 6 to 945 to 60 minLevel: Some experience

    Reaction timer

    Wait for the dot, then press A as fast as you can: learners time their reactions in milliseconds and analyse the class's data.

    Subjects: Mathematics · Coding and Robotics

    Code with: MakeCodePython

micro:bit is a trade mark of the Micro:bit Educational Foundation, and BBC is a trade mark of the British Broadcasting Corporation. Maze Education is an independent reseller of genuine BBC micro:bit products. Our teacher training and our other products and services are our own, and are not endorsed by the Foundation or the BBC.

WhatsApp