Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 3 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
Hand tools and fabrication machines | ||||||
![]() |
| |||||
![]() |
|
Everything fits inside of a pencil box to be placed near your door
I used an old smoke alarm siren
1 / 3 • Magnetic reed sensor for door
Door Alarm Sensor Setup
The yellow LED remains on all the time. The red LED blinks and the buzzer sounds when the door is opened/ alarm is triggered. The alarm does not stop until you press the reset button on the arduino or disconnect from power. I used a Wemo plug to set the time that I want the alarm to be on and to have easier access to an OFF switch in case the alarm sounds.
int buzzer = 9;
int red = 13;
int yellow = 12;
int yellowState = LOW;
int REED = 3;
int redState = HIGH;
int proximity = LOW;
int proximityprevious = LOW;
void setup(){
pinMode(yellow,OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(red, OUTPUT);
pinMode(REED, INPUT_PULLUP);
if (yellowState == LOW)
tone(buzzer,2500);
delay(900);
noTone(buzzer);
}
void loop(){
proximity = digitalRead(REED);
if (proximityprevious == HIGH)
{
proximity = HIGH;
}
if (proximity == HIGH)
{
proximityprevious = HIGH;
yellowState = LOW;
digitalWrite(red, HIGH);
delay(45);
digitalWrite(red, LOW);
delay(5);
tone(buzzer, 3000);
delay(200);
noTone(buzzer);
delay(100);
}
else
{
yellowState = HIGH;
redState = LOW;
}
{
digitalWrite(red,redState);
digitalWrite(yellow,yellowState);
}
}
Comments
Please log in or sign up to comment.