Home Security Alarm System

by Jyothir Krishnan in Circuits > Arduino

991 Views, 9 Favorites, 0 Comments

Home Security Alarm System

Final Project Grade 12 - Jyothir.png
Screenshot 2021-06-22 141245.png

Today, we will create a home security alarm that will detect motion using a PIR sensor and let you know an intruder is in your house. After sensing motion, the person has exactly 10 seconds to deactivate the alarm and if failing to do so the sound alarm will go off alerting everyone in the house. This project is very fun to build and it has a very practical use in your house, it also ensures your safety from intruders as well as saving you some money from buying security systems.

This is the tutorial that will guide you from beginning to end with an easy step of course. Let's get started!

Supply Purchase

F220Y8HKBKSQEPR.png

For this project, you will have to purchase some materials but no need to worry, I will list all the materials required for this project and will provide you links to where you can buy them if you don't already own them.

Setting Up Your Password

truth.png
IMG_20210622_141657917.jpg
1.png
not.png
and.png

Our first set in starting this project is to get a password set up for the alarm system. In order to do this, we will use logic gates and a DIP switch. Firstly, we need to make a truth table for 4-inputs and set only one combination which will result in giving a high output, refer to the truth table above for an example. This combination for your alarm can be anything of your choice but it has to be one of the 16 combinations listed in the truth table above. After creating your truth table and selecting your desired password, you will need to do the Sum Of Products (SOP) to create a boolean equation. For people who don't know what the sum of products is, it is a recipe for creating a circuit that can produce an output for any given truth table. For any single output and any number of inputs, we can produce a circuit using this method. Please refer to this video if you do not know how to do the sum of products. Now that you have your boolean equation we can get to making the schematic now, for my boolean equation there are 3 AND gates and 2 NOT gates, you can calculate how many gates are in your boolean equation. We only need to use one AND chip (74HC08)and one NOT chip (74HC04) as it is more than sufficient. then to make your schematic you need to label 4 inputs (A, B, C, D) like in the picture above and run it through the gates in sequential order to get your output. Now we have made your 4-digit password for your alarm system, so using this schematic we just hook up the wires on Tinkercad or Personal Arduino. Please refer to the Tinkercad circuit image above for your reference and the logic chips schematics to wire the inputs and outputs correctly.

*Please colour Code your wiring to make it easy to view and understand your wiring*

Setting Up the 7-Segement Displays

2.png

Now that we set our password and got that out of the way, we need to set up the 7-Segment displays for the timer. This is to ensure that if the alarm isn't shut off within the given time limit it will go off. Now setting this up isn't too difficult, all we have to do is get the wiring right and we are perfectly fine. I will link a picture of the pins of the 7-segment display above for your reference, but to start off we first need to connect the VCC/Common pins on both ends of the two displays to the power from Arduino using the 330Ω resistors. Refer to the image above for reference. Now comes the hard part, we need to wire the rest of the pins to the Arduino correctly for the code to work easily for you, if you choose to wire it in your own way you have to make sure to change the output pins accordingly in your code. Here a list of each pin and where it goes on the Arduino:

7-Segment Display #1:

  • Pin A - Arduino Pin 4
  • Pin B - Arduino Pin 5
  • Pin C - Arduino Pin 6
  • Pin D - Arduino Pin 7
  • Pin E - Arduino Pin 8
  • Pin F - Arduino Pin 3
  • Pin G - Arduino Pin 2

7-Segment Display #2:

  • Pin A - Arduino Pin 1
  • Pin B - Arduino Pin 0
  • Pin C - Arduino Pin 11
  • Pin D - Arduino Pin 12
  • Pin E - Arduino Pin 13
  • Pin F - Arduino Pin 9
  • Pin G - Arduino Pin 10

After hooking up the pins accordingly, you have successfully set up your 7-Segment displays and are ready to move to the next step.

*Please colour Code your wiring to make it easy to view and understand your wiring*

Setting Up PIR Motion Sensor and Piezo

3.png
pir.jpg
piezo.jpg

We are almost done creating our project, we now just need to wire in our PIR Motion Sensor and Piezo and write the code. I will attach a diagram of both the PIR and Piezo for your reference of the pins. First, we'll wire the PIR motion sensor to the Arduino. Take 2 wires and connect the power/VCC pin to the 5V power in the Arduino, and connect the GND to the ground on the Arduino. Finally, take another wire and connect the signal pin on the PIR to pin A1 on the Arduino. Now we'll move on to wiring the Piezo, this is very simple. Take 2 wires, connect the positive end (red) of the piezo to the Arduino pin A2 and take the other wire to connect the negative end (black) to the ground. Now you have successfully wired all the components of the circuit and you are ready to move onto the code.

*Please colour Code your wiring to make it easy to view and understand your wiring*

Writing the Code

Now we are done with all the circuitry and all we need to do now is to write the code. The code is moderate in difficulty for this project but the logic is straightforward. I have attached to code for this circuit above, but let us understand what this code actually does.

First we initialize all the variables and pins in the arduino in the code. After declaring all the variables and the pin they are desgnatied too, we set the pins to be either an input pin or an output pin to designate the function for the components. For example we set the PIR sensor pin to be an input as we are trying to dedect motion and send it to the arduino, and the 7-Segement display pins are all set to output because we are trying to show the time to the user based on the PIR input we recieve. After we setup all the pins, we are creating functions to display numbers on the 7-Segement display. Finally, in our main function we read motion from the PIR sensor, and if it is true it starts the alarm countdown using a for loop. If the user doesn't enter the correct password within the designated time the alarm will go off, and the person has to enter the correct password to disable it.

*If the code doesn't work correctly, please ensure the correct libraries are imported for you and check that you initialized all the pins correctly and check for typos*

Enjoy!!

Final Project Grade 12 - Jyothir.png

Finally, you are done with this project! Hopefully, you enjoy it, and be proud of what you achieved by yourself today!!

Have fun creating future Arduino projects!