diff --git a/IOT(Internet of Things)/Intermediate/Home Security System/Images/home_security_system.PNG b/IOT(Internet of Things)/Intermediate/Home Security System/Images/home_security_system.PNG new file mode 100644 index 000000000..414afaa6b Binary files /dev/null and b/IOT(Internet of Things)/Intermediate/Home Security System/Images/home_security_system.PNG differ diff --git a/IOT(Internet of Things)/Intermediate/Home Security System/Images/home_security_system.mp4 b/IOT(Internet of Things)/Intermediate/Home Security System/Images/home_security_system.mp4 new file mode 100644 index 000000000..c53cc3358 Binary files /dev/null and b/IOT(Internet of Things)/Intermediate/Home Security System/Images/home_security_system.mp4 differ diff --git a/IOT(Internet of Things)/Intermediate/Home Security System/README.md b/IOT(Internet of Things)/Intermediate/Home Security System/README.md new file mode 100644 index 000000000..d036fcec4 --- /dev/null +++ b/IOT(Internet of Things)/Intermediate/Home Security System/README.md @@ -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) + + + + diff --git a/IOT(Internet of Things)/Intermediate/Home Security System/home_security_system.cpp b/IOT(Internet of Things)/Intermediate/Home Security System/home_security_system.cpp new file mode 100644 index 000000000..b816df364 --- /dev/null +++ b/IOT(Internet of Things)/Intermediate/Home Security System/home_security_system.cpp @@ -0,0 +1,118 @@ +#include // Include library for LCD. +#include // Include keypad library. +#include + +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); + + +} diff --git a/IOT(Internet of Things)/Intermediate/Home Security System/requirements.txt b/IOT(Internet of Things)/Intermediate/Home Security System/requirements.txt new file mode 100644 index 000000000..ee7beae52 --- /dev/null +++ b/IOT(Internet of Things)/Intermediate/Home Security System/requirements.txt @@ -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 | diff --git a/IOT(Internet of Things)/README.md b/IOT(Internet of Things)/README.md index f0880f56c..98454c62f 100644 --- a/IOT(Internet of Things)/README.md +++ b/IOT(Internet of Things)/README.md @@ -30,7 +30,7 @@ | S-No. | Projects | S-No. | Projects | S-No. | Projects | |:--:|:--:|:--:|:--:|:--:|:--:| -| 01. | [Gas leakage detection](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Intermediate/gas%20leakage%20detection) | 02. | [Vehicle Accident Prevention System](https://github.com/rittikadeb/Project-Guidance/tree/vehicle-accident-prevention/IOT(Internet%20of%20Things)/Intermediate/Vehicle%20Accident%20Prevention%20System) +| 01. | [Gas leakage detection](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Intermediate/gas%20leakage%20detection) | 02. | [Vehicle Accident Prevention System](https://github.com/rittikadeb/Project-Guidance/tree/vehicle-accident-prevention/IOT(Internet%20of%20Things)/Intermediate/Vehicle%20Accident%20Prevention%20System) | 03. | [Home Security System](./Intermediate/Home%20Security%20System) ## Level 3: Advanced 🚀