5. Case 02: Security Vanguard Alarm System¶
Level:
5.2. Background¶
What is a Security Vanguard Alarm System?
Security vanguard alarm system is a smart defense system that triggers an alert automatically when detecting an unexpected visit. It is good to have security system to prevent from the theft coming in.
Vanguard Alarm System Principle
Motion sensor and distance sensor is implemented over the house and monitor the surrounding environment to check if there are visitors. If there are moving objects nearby, the sensors will reflect data to the system and trigger the buzzer with master icon shown on the micro:bit, until the objects move away.
5.3. Part List¶
5.4. Assembly step¶
Step 1
To start with, build the Big House Model.
Step 2
For extra room installation, Insert the model D1, D3 on model B1, align with the holes on model A.
Step 3
Attach the distance sensor to the Model D3 using M4 * 10mm screws and nuts.
Step 4
Put the model D2 on the holes of model A, and then insert it to model D1 and D3.
Step 5
Add the 4 rubber bends to the model D2 so that the house will not loose.
Step 6
Insert the model D4 to the model B1, and then attach it to the model D1, D2 and D3.
Step 7
Completed.
Step 8
Attach motion sensor to the model B1 (near the door) using M4 * 10mm screws and nuts. And the connecting wire should be bended to the hole above it.
Step 9
Assembly Completed!
5.5. Hardware connect¶
Connect the Motion sensor to P2
Connect Distance Sensor to P14,P15
Pull down the buzzer switch to connect buzzer
5.6. Programming (MakeCode)¶
Step 1. Create and save the reading to variable
Create two variable
distance
andmotion
In
Forever
, use (set distance toGet distance unit cm trig P14 echo P15
) to save the reading of distance to variabledistance
Use (set motion to
Get motion (triggered or not) at Pin P2
) to save the result of motion detection to variable
Step 2. Examine the reading
Snap
if-else
intoForever
after saving reading to variables.To check both distance and motion result, the condition should include two comparison and one extra logic operators
set the condition as [(
motion = true
) or (distance < 10
)]
Step 3. Defend!
In the
if
segment, means someone passing infront the door, show a angry icon byshow icon
Also play a warning sound to expel the suspicious by
play melody at tempo 120 (bpm)
In the
else
segment, no one is stay around home, no need to show the angry face, useshow leds
to clear up.Add a 1 second interval
pause (ms) 1000
for the security system running in 1 second sampling rate
Full Solution
MakeCode: https://makecode.microbit.org/_cc21MTdEuhMv
You could also download the program from the following website:
5.7. Result¶
When someone is get close to the door, either distance sensor or motion sensor will detect it and warn alert to house owner.
5.8. Think¶
Q1.Except simply triggering the alarm system, what else do you think a smart vanguard system should have? (e.g. send notification/ call the police)
Q2. Are other positions able to place the motion sensor to get the defend effect? (e.g in the living room)