House Security System

by 711008 in Circuits > Arduino

128 Views, 2 Favorites, 0 Comments

House Security System

Screenshot 2023-01-25 22.41.46.png

Using the components we learned throughout the course, I made a home security system. How it works is when the card or keychain is tapped onto the RFID, the servo motor connected to the door will rotate 90 degrees (opening the door) and then when tapped again, the servo motor will rotate back 90 degrees (closing the door). Moreover, when a certain distance is read on the distance sensor, the led will turn on and if the push button is pressed, the buzzer will ring which will act as a doorbell.

Supplies

images.jpg
download.jpg
  • 1 led
  • 1 servo motor
  • cardboard
  • Arduino UNO
  • 2 breadboards
  • 1 NPN Transistors
  • light strips
  • 1 buzzer
  • 1 push button
  • Different resistors (10k, 330, 5k)
  • Wires
  • Wire cutters
  • plyers

Wiring the Rfid

The first step was to research and understand how the RFID works and how to wire and code it. I also needed to wire the servo motor on the Arduino and code it as well. After researching how the RFID works, I started to wire the RFID as well as the servo motor neatly so that it would fit my project. Moreover, I also had to wire the power and ground pins to the Arduino so that my breadboard had power and ground running through it.

Started Wiring the Distance Sensor and Led

I started to wire the distance sensor on the breadboard as well as the led, buzzer and push button. The first step was to make sure that specific components acquired the power and ground with the appropriate resistance. After adding the components to the breadboard, it was time to add them to the Arduino pins in order to start the code!

Coding the Rfid and Servo Motor

Like I stated earlier, I needed to servo motor to rotate 90 degrees when the Rfid card is tapped and then back 90 degrees for when the Rfid card is tapped again. Therefore, I needed to plug those components into the Arduino pins.


Vcc: 3.3v

RST: 2

GND: GND

MISO :3

 MOSI: 4

SCK :5

NSS : 6

IRQ :7

Buzzer: 8

Pushbutton: 10

Echo:11

Trig:12

led:13

Servo motor:9

Coding (variables)

Screenshot 2023-01-25 150759.png

In order to start off the code, I needed to initialize/define my variables. Doing so will allow me to control the pins of the Arduino and control what specific components will do. Here is the file to the code.

Setup Function

Screenshot 2023-01-25 151013.png

After setting up and defining the variables. We now need to set each component to either input or output in order to actually connect it to the pin. For example, I have the button set to input because it will take the value from when someone presses on the button. Then, I had the buzzer set to output because when the button takes in the value, the buzzer will output a sound.

Loop Function

Screenshot 2023-01-25 152701.png

The first step is to code the distance sensor with the led. The first section of the code will work as the following; if the distance is less than or equal to 5 inches, then the led will turn on, however, if the distance reads more than 5 inches, then the led will stay off. In addition, if the button reads high (stating that it has been pressed), then the buzzer will read high as well producing a sound that will act like a doorbell. Moreover, through the RFID code, when the card is tapped (value is read) then the servo motor will start to rotate 90 degrees, however, if the card is tapped again, the servo motor will rotate back 90 degrees.

Step Seven

download.jpg

Attach a cardboard/paper onto the servo motor in order to test if the system/project works as intended.