Advertisement
arduino security alarm circuit

Arduino Security Alarm with Reed Switch

Here is a simple general-purpose security alarm circuit built on the Arduino platform. It brings up an obtrusive alert signal when an intrusion/theft attempt is observed by its front-end sensor. In addition, an LCD screen is wired to enhance the system performance. The whole system can be energized from any suitable 9VDC supply source.

Related Products: Electromechanical Switches | Switch Indicators

Schematic of the Arduino Alarm System Circuit

arduino security alarm circuit

How does the security alarm circuit works?

When power is turned on, the circuit goes into standby mode, and this condition is indicated by “SECURITY ALARM” in the LCD screen.Note that here a N/O reedswitch + bar magnet combination is used to detect any mishaps, and hence the reed switch should be in “closed”state at standby mode. When reed switch is opened, pin 2 of Arduino goes high with the help of the pull-up resistor R2, and the alert signal is available through the piezo-speaker PZ1 (not an active piezo-buzzer).

At the same instant “ALERT ACTIVATED” message is displayed on the LCD screen. Once triggered, this “ALERT ACTIVATED” message remains lit until the system is resetted by the “reset” switch in the arduino board. In this way the owner is informed that the alert went off atleast once during his/her absence. Components R1 (100R) is added to limit the operating current of the LCD backlight unit, and P1 (10K) is the display contrast controller.

Related Products: Switch Other Switch Reed Switch Safety Interlock

Arduino Sketch

// ARDUINO-BASED SECURITY ALARM //
// T.K.Hareendran //
#include  
int sensPin = 2; // Sensor Input Pin
int ledPin = 13; // LED output Pin
int pzSpeaker = 5; //Piezo-speaker Output Pin
int val = 0; // variable for reading the Input Pin status
LiquidCrystal lcd (7, 8, 9, 10, 11, 12);
void setup() {
   pinMode(sensPin, INPUT); // Set Sensor as input
   pinMode(pzSpeaker, OUTPUT); // Set Piezo-Speaker as output
   pinMode(ledPin, OUTPUT); // Set LED as output
   lcd.begin(16, 2); 
   lcd.print(" SECURITY ALARM");
}
void loop(){
   val = digitalRead(sensPin); // read input value
   if (val == HIGH) { // check if the input is HIGH
      digitalWrite(ledPin, HIGH); // turn LED ON
      lcd.setCursor(0, 1);
      lcd.print("ALERT ACTIVATED!");
      playTone(500, 600);
      delay(100);
      playTone(500, 800);
      delay(100);
   } else {
      digitalWrite(ledPin, LOW); // turn LED OFF
      playTone(0, 0);
      delay(300);
   }
}
// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
   duration *= 1000;
   int period = (1.0 / freq) * 1000000;
   long elapsed_time = 0;
   while (elapsed_time < duration) {
      digitalWrite(pzSpeaker,HIGH);
      delayMicroseconds(period / 2);
      digitalWrite(pzSpeaker, LOW);
      delayMicroseconds(period / 2);
      elapsed_time += (period);
   }
}

Photos

Learning Point
– Arduino → Switch Status Detector
– Arduino → LCD driver
– Arduino → Alarm Sound Generator

4 Comments

Join the conversation!

Error! Please fill all fields.
  • mk_3249

    If I would like to add more than 1 reed switch like 10 to 15 then how to connect and I also want to add 4 PIR sensors. Pls. suggest.

  • thusitha

    Sir,
    Can i know about that. i want make home securite system with arduino and my gsm modem. i saw yor project. Can i add differant situation i mean differant massages. signal in to anlog or digital inputs? ((((((((((((((((((

    pinMode(msg_key,INPUT); pinMode(call_key,INPUT); pinMode(end_key,INPUT); digitalWrite(msg_key,HIGH); digitalWrite(call_key,HIGH); digitalWrite(end_key,HIGH);}void loop(){ //Sends an sms everytime msg_key is pressed if (digitalRead(msg_key)==LOW) // Check if the sms key is being pressed { mySerial.println(“AT+CMGF=1”); // Set the Mode as Text Mode delay(150); mySerial.println(“AT+CMGS=\”+00″+number+”\””); // Specify the Destination number in international format by replacing the 0’s delay(150); mySerial.print(“Warning! Intruder Alert!”); // Enter the message delay(150); mySerial.write((byte)0x1A); // End of message character 0x1A : Equivalent to Ctrl+z delay(50); mySerial.println(); })))))))))))))

    Must i change this location like a

    pinMode(msg_key1,INPUT); pinMode(msg_key2,INPUT); pinMode(mag_key3,INPUT); digitalWrite(msg_key1,HIGH); digitalWrite(msg_key2,HIGH); digitalWrite(msg_key3,HIGH);

    With differant pin
    Please i want need your help
    Thank you………

  • Ahmed

    pls. Send me cod and diagrams for Fire Alarm system Controlled By Using Microcontroller ardoino uno
    Thank you for your help me
    Best regard
    Ahmed

  • jitendra

    electroschematics has been giving very excellent educational help to me since I have subscribe to their website.May they keep up with their good work.Thanks.

Looking for the latest from TI?