When this security system is activated, then when both pieces of magnet are separated, the arduino will detect a logical change from 0 to 1 and upside down. So that when someone opens the door then the alarm will sound and automatically the garden light is also on. Garden lights are installed in the room with the light beam at the door. Relays as actuators that will control ON / OFF Alarm and garden lights. The START / STOP button is used to activate the system as well to turn off Alarm and garden lights.
Hardware Requirement
- Arduino Uno Board
- Reed sensor magnetic module
- 2 Relay
- Alarm AC (Sirine)
- Push Button
- LED Indicator
- Soptlight
- Power supply +5 Volt
- Jumper
Block Diagram
Schematic
Arduino - Magnet Sensor Wiring
Arduino - Other Component Wiring
Source Code/Sketch
int inSensor = 8;
int tbStSp = 9;
int alarm = 10;
int lamp = 11;
int indicator = 12;
boolean Start=false;
void setup(){
pinMode(inSensor, INPUT);
pinMode(tbStSp, INPUT);
digitalWrite(inSensor, HIGH);
digitalWrite(tbStSp, HIGH);
pinMode(alarm, OUTPUT);
pinMode(lamp, OUTPUT);
pinMode(indicator, OUTPUT);
digitalWrite(alarm, LOW);
digitalWrite(lamp, LOW);
digitalWrite(indicator, LOW);
}
void loop(){
if (digitalRead(tbStSp)==0){
Start=true;
digitalWrite(indicator, HIGH);
delay(500);
}
if (digitalRead(inSensor)==1 && Start==true){
digitalWrite(alarm, HIGH);
digitalWrite(lamp, HIGH);
delay(2000);
while(digitalRead(tbStSp));
digitalWrite(alarm, LOW);
digitalWrite(lamp, LOW);
digitalWrite(indicator, LOW);
Start=false;
delay(1000);
}
}
int tbStSp = 9;
int alarm = 10;
int lamp = 11;
int indicator = 12;
boolean Start=false;
void setup(){
pinMode(inSensor, INPUT);
pinMode(tbStSp, INPUT);
digitalWrite(inSensor, HIGH);
digitalWrite(tbStSp, HIGH);
pinMode(alarm, OUTPUT);
pinMode(lamp, OUTPUT);
pinMode(indicator, OUTPUT);
digitalWrite(alarm, LOW);
digitalWrite(lamp, LOW);
digitalWrite(indicator, LOW);
}
void loop(){
if (digitalRead(tbStSp)==0){
Start=true;
digitalWrite(indicator, HIGH);
delay(500);
}
if (digitalRead(inSensor)==1 && Start==true){
digitalWrite(alarm, HIGH);
digitalWrite(lamp, HIGH);
delay(2000);
while(digitalRead(tbStSp));
digitalWrite(alarm, LOW);
digitalWrite(lamp, LOW);
digitalWrite(indicator, LOW);
Start=false;
delay(1000);
}
}
How it Works
1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.
3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. Install the magnetic sensor on the door.
6. Press the Start button to activate the system.
7. Alarms and Lights are on when the door is opened.
8. If the door is closed the alarm and lights stay on, to turn off the alarm and lights
Press the Start / Stop button.
9. To activate the system again press the Start / Stop button.
Video for Project V - 20. Door Security System using Magnetic Sensor based On Arduino
Required file
No comments:
Post a Comment