Today security is very important and without security most of the things in this world are not safe. Today most of places, instrument, personal used devices, instrument used in home etc all are build with at least one type of security features for protecting them. So today we learn about how to design the simple security device. We design a simple device for protecting our house product from thief or alarming us from the unknown guest. Our main aim in this lesson is to design the system when any man cross the door then alarm will automatically run until it is not off and when any member from home passes the door/main door by pushing the alarm switch he/she can off the the alarm for few seconds like 5 sec to 10 sec which is designed by programming. In this tutorial we design the system from arduino and ultrasonic sensor and some other component.
Step 1: Required Components
The components required for this build the system are:
- Arduino uno R3 (or any type)
- Ultrasonic Sensor module HC-SR04
- Breadboard (not compulsory)
- Jumper wire
- speaker with USB power
- push button switch
- LED(red and green)
Step 2: Circuit Connection
Here we do all the connections in the breadboard. Due to wiring of component is easy on the breadboard and proper. Breadboard is best source for designing any circuit due to no soldering of wire for connection of component. Proper connections is very important for complete working of the devices which is assemble so please do proper connection. Here we do connections of ultrasonic sensor module and speaker with arduino uno.
- Connection of Ultrasonic sensor module HC-SR04 With arduino
Here we use HC-SR04 ultrasonic senor module for detecting person or any thing who cross the door. when any person cross the door then sensor send the signal to the controller who generate the sound signal.There are 4 pin available in the sensor module which is VCC, TRIG, ECHO, GND. connection of the pin is given below.
VCC - connect to the 5 volt
GND - connect to the ground
ECHO-Sensor echo pin connected to Arduino pin 11
TRIG- Sensor Trig pin connected to Arduino pin 13.
- Connection of speaker with arduino
we use speaker for playing the sound signal generated by the arduino for alert purpose. you can use different type of speaker depending upon the type of application or your purpose. speaker receives the signal and play it. There are 2 pin available is the USB for signal one is +V and one is -V, -V pin is connected to GND and +ve pin is connected to arduino pin 9 (PWM) and two other pin is available in speaker for power +V and GND or usb supply. provide the power to the speaker from arduino or external power source.
- Connection of switch
connect the one terminal of switch to GND of arduino and other terminal to the RESET pin of arduino.
- Connection of green LED
connect the green led anode (+ve) to the 5v supply and cathode (-ve) to the GND, green LED is used as a indicator for device is running or not.
- Connection of RED LED
connect the red led anode (+ve) to the arduino pin 6 supply and cathode (-ve) to the GND, red LED is used for indication when alarm is running or speaker emit the sound .
Step 3: Working
For proper working of alarm we must know is designing the system.First supply the power to arduino and speaker by dc power source like 5v adaptor etc, when device is powered then green LED will glow,and wait 5 second for complete running of the devices, when any one cross the door then sensor send to the signal to the arduino and arduino generate the sound signal which is send to the speaker.
Working of switch :- when any one press the switch then device stop working for 5 second after 5 sec devices will run continuously , this also stops the running alarm. when power is supplied wait 5 second for proper working of device to start .
Step 4: The Code
After completing all the connections of hardware then go to the software part. Here you write the code in the arduino IDE in the assembly language. Copy the code into arduino IDE and upload it into the arduino uno.
time = pulseIn(echo, HIGH);
if(dist<=xxxxx) // replace xxxxx to the width of door in cm maximum range will be 400 cm
for(double x = 0; x < 0.92; x += 0.01)
tone(9, sinh(x+8.294), 10);
for(double x = 0; x < 0.183258; x += 0.002)
tone(9, sinh(-5* (x-1.8420681)), 10);
Step 5: RESULT
After completing all the part successfully your devices is ready . Place the sensor module and switch according to your need. After completion when any person cross the door then red led will glow and alarm will play and also test the working of switch.