-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #947 from rittikadeb/home-security-system
Added Home Security System
- Loading branch information
Showing
6 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
Binary file added
BIN
+113 KB
...et of Things)/Intermediate/Home Security System/Images/home_security_system.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.74 MB
IOT(Internet of Things)/Intermediate/Home Security System/Images/home_security_system.mp4
Binary file not shown.
66 changes: 66 additions & 0 deletions
66
IOT(Internet of Things)/Intermediate/Home Security System/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Home Security System | ||
|
||
|
||
## Aim | ||
|
||
To design a Arduino Based Home Security System | ||
|
||
|
||
## Purpose | ||
|
||
This low-cost and effective system helps you to protect your house from thieves/intruders. | ||
|
||
|
||
## Components Required | ||
|
||
* Arduino UNO | ||
* Breadboard | ||
* Connecting Wires | ||
* LCD | ||
* Potentiometer | ||
* Keypad | ||
* PIR Sensor | ||
* Servo Motor | ||
* Buzzer | ||
* 1 Red LED | ||
* 1 Green LED | ||
* 4 Resisitors | ||
|
||
## Short Description | ||
|
||
In this project, we are using PIR Motion Sensor Module as an infraredsensor that generates electric charge when exposed in heat and sends a signal to Arduino. Accordingly the Arduino displays the status on LCD screen and start buzzing the buzzer and glows the LEDs. | ||
|
||
## Workflow of the Project | ||
|
||
- The servo motor acts like the lock | ||
- When ths system is not locked the green LED is turned on and a LOCK INACTIVE message is displayed on the LCD Screen. | ||
- When the system is locked by giving the default password through the keypad: | ||
- Servo rotates | ||
- Secured message is displayed on the LCD | ||
- When any movement is detected by the PIR Sensor: | ||
- Red LED is turned on | ||
- Warning message is displayed on the LCD | ||
- Buzzer is turned on | ||
- When again the default password is inputed : | ||
- Servo rotates back to the origial position | ||
- Lock is disarmed | ||
- Message displayed on the LCD screen. | ||
|
||
|
||
## Setup instructions | ||
|
||
- Design and assemble the circuit as shown in the image. | ||
- Check the connections of all the components. | ||
- Upload the code provided. | ||
- Start the simulation | ||
|
||
## Output | ||
|
||
![Circuit](https://user-images.githubusercontent.com/76259897/156227022-d60e95c8-9fc1-493c-b6eb-9fd0540929a6.png) | ||
|
||
|
||
[Simulation Video](./Images/home_security_system.mp4) | ||
|
||
|
||
|
||
|
118 changes: 118 additions & 0 deletions
118
IOT(Internet of Things)/Intermediate/Home Security System/home_security_system.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#include <LiquidCrystal.h> // Include library for LCD. | ||
#include <Keypad.h> // Include keypad library. | ||
#include <Servo.h> | ||
|
||
const byte rows = 4; | ||
const byte cols = 4; | ||
|
||
// Define the keymap. | ||
char keys[rows][cols] = { | ||
{'1','2','3','A'}, | ||
{'4','5','6','B'}, | ||
{'7','8','9','C'}, | ||
{'*','0','#','D'} | ||
}; | ||
|
||
byte rowPins[rows] = {2,12,11,10}; // Keypad ROW0, ROW1, ROW2 and ROW3 are connected to these Arduino pins. | ||
byte colPins[cols] = {9,8,7,6}; // Keypad COL0, COL1, COL2 and COL3 are connected to these Arduino pins. | ||
|
||
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols); // Create the keypad. | ||
|
||
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5); | ||
|
||
int sensor1 = 13; | ||
int state = 0; // State of the PIR sensor. | ||
bool motionDetected = false; | ||
bool locked = false; // Defines whether the program should listen for the data from sensor and respond to it or not. | ||
|
||
int ledGreen = 3; | ||
int ledRed = 4; | ||
|
||
Servo servo; | ||
|
||
int buzzer = 5; | ||
|
||
String passcode = "14"; // Default passcode | ||
String input = ""; // Input that will be read from keypad | ||
|
||
void setup() { | ||
pinMode(sensor1, INPUT); | ||
pinMode(ledGreen, OUTPUT); | ||
pinMode(ledRed, OUTPUT); | ||
pinMode(buzzer, OUTPUT); | ||
servo.attach(1); | ||
lcd.begin(16,2); | ||
} | ||
|
||
void loop() { | ||
if(locked == false){ // Check whether system is not locked. | ||
digitalWrite(ledGreen, LOW); | ||
lcd.setCursor(0,0); | ||
lcd.print("Lock Inactive"); | ||
servo.write(0); | ||
char key = keypad.getKey(); // Read key from keypad. | ||
if(key && key != '*'){ // Check whether key has been read from keypad and is not equal to "*" which is submit key. | ||
input += key; // Read passcode from keypad and store it in input variable. | ||
} | ||
if(key == '*'){ // Check whteher "*" submit key has been pressed on keypad. | ||
if(passcode == input){ | ||
locked = true; // Lock the system | ||
input = ""; // Clear input variable. | ||
lcd.clear(); | ||
lcd.setCursor(0,0); | ||
lcd.print("Secured"); | ||
lcd.setCursor(0,1); | ||
lcd.print(":D"); | ||
servo.write(90); | ||
delay(3500); | ||
lcd.clear(); | ||
} | ||
} | ||
} | ||
else if(locked == true){ // Check whether system is locked. | ||
char key = keypad.getKey(); // Read key from keypad. | ||
if(key && key != '*'){ // Check whether key has been read from keypad | ||
input += key; // Read passcode from keypad and store it in input variable. | ||
} | ||
if(key == '*'){ // Check whteher "*" submit key has been pressed on keypad. | ||
if(passcode == input){ | ||
locked = false; // Unlock the system | ||
input = ""; | ||
lcd.clear(); | ||
lcd.setCursor(0,0); | ||
lcd.print("Disarmed"); | ||
lcd.setCursor(0,1); | ||
lcd.print(":("); | ||
delay(3500); | ||
lcd.clear(); | ||
} | ||
} | ||
state = digitalRead(sensor1); | ||
delay(100); | ||
if(state == HIGH){ | ||
digitalWrite(ledGreen, LOW); | ||
digitalWrite(ledRed, HIGH); | ||
lcd.clear(); | ||
lcd.setCursor(0,0); | ||
lcd.print("Movement Detected!"); | ||
lcd.setCursor(0,1); | ||
lcd.print("Alert!!"); | ||
alarm(); | ||
delay(50); | ||
lcd.clear(); | ||
|
||
} | ||
else{ | ||
noTone(buzzer); | ||
lcd.setCursor(0,0); | ||
lcd.print("Lock Active"); | ||
digitalWrite(ledGreen, HIGH); | ||
digitalWrite(ledRed, LOW); | ||
} | ||
} | ||
} | ||
void alarm(){ | ||
tone(buzzer, 500); | ||
|
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
IOT(Internet of Things)/Intermediate/Home Security System/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
| Component | Quantity | | ||
| ------------------| ------------- | | ||
| Arduino UNO | 1 | | ||
| Breadboard | 1 | | ||
| Connecting Wires | 38 | | ||
| LCD | 1 | | ||
| Potentiometer | 1 | | ||
| Keypad | 1 | | ||
| PIR Sensor | 1 | | ||
| Servo Motor | 1 | | ||
| Buzzer | 1 | | ||
| Red LED | 1 | | ||
| Green LED | 1 | | ||
| Resisitors | 4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters