Safety and scope
This is an educational demonstrator and is not a certified security system.
Plan, predict and test
Suggested virtual study time: about 20 minutes. This is a planning estimate, not a validated construction time.
Preparation: Foundation electricity and basic programming logic. Adult supervision for children. Review a foundation lesson ↗
Use paper, a spreadsheet or a simulator. This is not a verified physical assembly guide.
- Scenario: Simulate PIR LOW, HIGH and warm-up states. Create a table of idle, motion and not-ready.
- Expected result: Do not trust the motion decision during warm-up.
- Checkpoint: Write your prediction, test it in the virtual model and explain any difference.
A correct answer does not certify the physical system.
Record your validation
Use only virtual inputs and indicators until the actual components, pinouts and electrical limits have been verified.
| Case | What to record |
|---|---|
| Normal input | D2 HIGH → LED ON; LOW → OFF |
| Boundary | A logic transition changes the indicator on the next sample |
| Missing or invalid input | The sketch does not model PIR warm-up or detect a disconnected input. Use a separate ready/valid flag in a real design. |
| Repeat test | Repeat the virtual test, record the actual output and compare with the expected result. |
These are test-planning requirements, not recorded hardware results.
Before building: understand the listed components and the relevant low-voltage safety rules. This is a concept brief, not a tested assembly manual.
What it does
Demonstrate motion detection, alarm arming and timed outputs in a small security-themed prototype.
Engineering principle
A PIR sensor detects changes in infrared energy across its field of view. It produces a digital output when movement is detected. The controller checks that the system is armed before activating an LED and buzzer for a configured duration.
Hardware and components
- Arduino Nano or UnoReads the PIR output and arming control.
- HC-SR501 PIR moduleDetects movement; sensitivity and hold time are adjustable on the module.
- Active buzzer and LEDProvide audible and visual alarm feedback.
- Arming switch or pushbutton (optional)Enables or disables the alarm state.
- Low-voltage supply and wiringPower the sensor and controller.
Suggested build sequence
- Allow the PIR module its startup stabilisation period.
- Adjust sensitivity and hold time using the module controls.
- Read the PIR output and confirm the active logic level.
- Use an arming state to decide whether motion should trigger the alarm.
- Add a timed alarm and a clear disarm/reset action.
Learning outcomes
- PIR sensing
- Digital event handling
- State variables and timers
- False-trigger testing
Possible upgrades
Add entry/exit delay, a keypad, multiple zones or local event logging.
Practice the core principle
This simplified exercise is not the full physical project shown above. Test in simulation first; verify real hardware against its datasheet. Children need adult supervision.
Reference components
- Arduino Uno
- Compatible PIR module
- LED
- 330 Ω resistor
- Jumper wires
Connection plan
- PIR OUT → D2 (verify compatible voltage)
- PIR VCC → specified module supply
- PIR GND → GND
- D8 → LED through 330 Ω; cathode → GND
Reference sketch
const int pir=2, led=8;
void setup(){
pinMode(pir,INPUT);
pinMode(led,OUTPUT);
}
void loop(){
bool motion=digitalRead(pir)==HIGH;
digitalWrite(led,motion?HIGH:LOW);
delay(50);
}How the code works
- pir and led are pin assignments.
- setup selects input/output modes.
- digitalRead samples motion output.
- digitalWrite reflects the sampled state; delay sets sampling interval.
Practice sequence
- Check module voltage and output specifications.
- Disconnect power, connect signal, power and common ground.
- Connect the indicator with its series resistor.
- Allow PIR warm-up, then test moving and stationary conditions.
Expected result
Observe LED on motion detection and off after module hold time.
Troubleshooting
If always on, allow warm-up and check sensitivity/hold-time settings.
Independent challenge
Count motion detection transitions without counting every sample.