avalosservando23
Published © GPL3+

Door Alarm Sensor (Wired)

Protect your home with a simple magnetic sensor and alarm with an arduino uno.

IntermediateFull instructions provided6,915
Door Alarm Sensor (Wired)

Things used in this project

Hardware components

Reed Switch, Magnet Switch Set
Reed Switch, Magnet Switch Set
×1
Arduino UNO
Arduino UNO
I used an Arduino Uno.
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
5 mm LED: Red
5 mm LED: Red
×1
Resistor 330 ohm
Resistor 330 ohm
×3
Resistor 10k ohm
Resistor 10k ohm
×1
Buzzer, Piezo
Buzzer, Piezo
I repurposed and old smoke alarm speaker.
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
(Optional)
Solder Wire, Lead Free
Solder Wire, Lead Free
(Optional)

Story

Read more

Schematics

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.

Code

Door Alarm Sensor Code

Arduino
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);

  

}
}
             

Credits

avalosservando23
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.