HOME SECURITY SYSTEM
Securtiy is one of the most sought after priveledges of today. With expensive jewellery, artifacts and phones and tablets kept in one's home, it is a necessity to have some sort of security system installed to protect these items.
For the very same reason, we have built, as a Mini Project for our Systems Management course, a Home Securtiy System prototype.
The Home Security System Prototype works with an Arduino Microprocessor, PIR Sensor, Sound Sensor, Buzzer and two LEDs ( red and green).
Install it on the side of a your door around 4 feet from the ground.
Enter the passcode to make the system active. Once active, the GREEN LED will turn ON.
Now, any attempt to enter the room guarded by the system will get detected by the motion sensor and the alarm will turn ON along the the RED LED letting you know about the intrusion.
There is another level of security provided by the security system prototype. Sounds above a certain amplitude is detected by the sound sensor and the alarm is set off.
Project Components
The following are the components used to build the prototype :
- Arduino Microprocessor (Any model)
- Passive Infrared Sensor (PIR Sensor)
- Sound Sensor
- Buzzer
- Red LED
- Green LED
- Breadboard
- Connecting Wires
- Laptop with Arduino IDE installed (for uploading code to the microprocessor)
- Type B USB cable
- 12 Input Keypad
Connection Overview
The basic connections to construct the prototype :
Arduino Microprocessor
The Arduino board, the most essential part of the security system, is a microprocessor. This board is used to interact with the environment using sensors.
It can be powered by a computer (using the USB cable) or by external power input.
Details of the Arduino used :
- Model No. : Arduino ATmega328
- Operating Voltage : 5V
- Flash Memory : 32 KB
- No. of Digital I/O Pins : 14
- No. of Analog I/O Pins : 6
- Input Voltage : 6-12 V
The board is coded using the Arduino IDE software. Download Link: http://arduino.cc/en/Main/Software
The code is written in C or C++ and uploaded to the microporcessor via a type B USB cable.
Environment Sensors
Two sensors were used in the security system.
1. PIR Sensor
The Passive Infrared Sensor (PIR) detects change in infrared (IR) light radiating from objects in its field of view. This sensor was used to detect unwanted/foreful entry into the house.
2. Sound Sensor
The sound sensor detects the sound strength in its direct environment. The main component of the module is a simple microphone. It outputs an analog signal according to the input it gets from the microphone.44
Both the sensors are tested by the Arduino board and their signal can be mapped as both boolean(either HIGH or LOW) or as analog(range[0,255]).
Code Logic
Let's look at the logic of the code used in the security system.
- Initially everything is set to OFF state.
- At the start of the program, listen for the passcode (which is hardcoded).
- If wrong password is given, reset the program.
- If the right password is given, turn on the GREEN LED and continue with the instructions below.
- Listen for input from the motion sensor and sound sensor.
- If any of the sensors give a high input, GREEN LED = OFF; BUZZER = ON; RED LED = Alternating ON/OFF
- Run '6' till Reset button is pressed.
Here is the code uploaded to the Arduino for our home security system.
#include <EEPROM.h>
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
;
char keys[ROWS][COLS] =
{{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}};
byte rowPins[ROWS] = {
8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
4, 3, 2}; // connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int redLed = 9;
int greenLed = 10;
int buzzer = 11;
int motionPin = 12;
int soundPin = 13;
int GetNumber()
{
char key = keypad.getKey();
return key;
}
int passcode()
{
int ctr=0, key1, key2, key3, key4;
while(ctr!=1)
{
key1=GetNumber();
if(key1)
{
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
ctr=1;
}
}
ctr=0;
while(ctr!=1)
{
key2=GetNumber();
if(key2)
{
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
ctr=1;
}
}
ctr =0;
while(ctr!=1)
{
key3=GetNumber();
if(key3)
{
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
ctr=1;
}
}
ctr=0;
while(ctr!=1)
{
key4=GetNumber();
if(key4)
{
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
delay(100);
ctr=1;
}
}
if( key1 == '1' && key2 == '2' && key3 == '3' && key4 == '4' )
{
return 1;
}
else
{
return 0;
}
}
void setup()
{
for (int i = 0; i < 512; i++)
EEPROM.write(i, 0);
pinMode(soundPin,INPUT); //SIG of the Parallax Sound Impact Sensor connected to Digital Pin 7
pinMode(motionPin,INPUT);
pinMode(buzzer, OUTPUT);
pinMode(greenLed,OUTPUT);
pinMode(redLed, OUTPUT);
digitalWrite (greenLed,LOW);
}
void loop()
{
boolean soundstate;
boolean motionstate;
int run=0;
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
delay(100);
run = passcode();
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
delay(100);
switch(run)
{
case 1 : {
digitalWrite (greenLed,HIGH);
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
delay(100);
while( motionstate!=1 || soundstate!=1 )
{
soundstate = digitalRead(soundPin);
motionstate = digitalRead (motionPin);
if (soundstate == 1 || motionstate == 1 ) {
digitalWrite(buzzer, HIGH);
digitalWrite(greenLed,LOW);
for(int i=0;;i++)
{
digitalWrite(redLed,HIGH);
delay(500);
digitalWrite(redLed,LOW);
delay(500);
}
}
else{
digitalWrite(buzzer,LOW);
digitalWrite(greenLed,HIGH);
digitalWrite(redLed,LOW);
}
}
}
break;
default :
{
delay(100);
digitalWrite(buzzer,HIGH);
delay(75);
digitalWrite(buzzer,LOW);
delay(75);
digitalWrite(buzzer,HIGH);
delay(75);
digitalWrite(buzzer,LOW);
delay(75);
digitalWrite(buzzer,HIGH);
delay(75);
digitalWrite(buzzer,LOW);
delay(75);
digitalWrite(buzzer,HIGH);
delay(75);
digitalWrite(buzzer,LOW);
delay(75);
}
break;
}
}
Demonstration
Authors
Lohitaksh Parmar - 2014059
Nalin Gupta - 2014065