At polish site named http://majsterkowo.pl/ I found an article about alarm system using a Arduino board and PIR sensor.
Base schematic is
and sketch for alarm is at page 3 in article.
After I translate name of variables and study original sketch, I made some changes:Note: I use internal led from Arduino board instead buzzer.
My sketch is alarm_system_1a.ino and I have next states:
- switch is open, blue led is on, alarm is deactivate;
- switch is close (D2 at GND), green led is blinking, alarm is in stand-by
- after 20 seconds, green led in on, alarm is waitting
- if PIR sensor detect a movement, red led is blinking, alarm countdown
- after 10 seconds, if switch is still close, red led is on, buzzer is active
- after 10 seconds, alarm return to waitting, if is movement, alarm countdown and repeat the cycle
- if switch is open, system in off.
You can see a movie named Arduino system alarm with delay with all states: