Programming a simple alarm system
Design & Technology · Key Stage 2 · The School
The basic rule
A simple alarm follows one rule. IF the sensor detects something, THEN sound the buzzer. This is the same input-process-output shape from an earlier lesson. It is now used for one job. That job is warning somebody that something has happened. Every real alarm system, however complicated, starts from this same one-line idea.
Adding a reset
A buzzer that starts and never stops is not much use. Add a RESET step. It is a button that switches the alarm off again. That turns a one-shot warning into something a person can actually live with. Almost every real alarm needs a way to be turned off. Forgetting this one small step can make an otherwise good design unusable.
Testing and improving it
A first version might go off too easily. Even the smallest twitch from the sensor could set it ringing, again and again, for no real reason. Testing it for real is what shows this up, not just reading the code. The fix is usually small: a short delay, or a threshold. It rarely needs a whole new design.
FIRST VERSION: IF the door sensor changes at all, THEN sound the buzzer. Tested for a day, it goes off dozens of times. Draughts alone are enough to set it off. FIXED VERSION: IF the door sensor changes AND stays changed for more than two seconds, THEN sound the buzzer. A manual reset button is added too, to silence it. The rule is barely any longer. But testing the first version for real is what found the fix. Reading the code alone never would have.