World's Loudest Arduino Intruder Alarm
by geekrex in Circuits > Arduino
17978 Views, 150 Favorites, 0 Comments
World's Loudest Arduino Intruder Alarm
![COVER.jpg](/proxy/?url=https://content.instructables.com/F8F/DY17/IJP240A2/F8FDY17IJP240A2.jpg&filename=COVER.jpg)
![IMG_1977.JPG](/proxy/?url=https://content.instructables.com/FPL/ZK98/IJP234O8/FPLZK98IJP234O8.jpg&filename=IMG_1977.JPG)
![IMG_1980.JPG](/proxy/?url=https://content.instructables.com/FEI/CDOD/IJP23G8T/FEICDODIJP23G8T.jpg&filename=IMG_1980.JPG)
I am such a guy who loves his thing very much and specially i don't like any one coming to my work space without my prior knowledge,mostly if the persons are my sibling or young kids.I need a way to make an alarm to help me protect my space and guard it properly.
But buzzer are too low in volume to implement.Until i got this . A freaking loud siren from DNA technology.
It was so loud that i had to wear plugs before i had to turn it on.
I just loved it but also needed to decrease the volume of the siren , which i achieved by using a pwm ,which i will explain later.
I coded a simple sketch in arduino to input from a ultrasonic sensor and if their is somebody near 100 cm of my workplace it ativates te alarm and stays on still the person is present.
Also like my page for support
https://www.facebook.com/makewithRex
Items
![IMG_1983.JPG](/proxy/?url=https://content.instructables.com/F8D/H3KC/IJP234OI/F8DH3KCIJP234OI.jpg&filename=IMG_1983.JPG)
![IMG_1984.JPG](/proxy/?url=https://content.instructables.com/FGN/OIFJ/IJP234OK/FGNOIFJIJP234OK.jpg&filename=IMG_1984.JPG)
![IMG_1987.JPG](/proxy/?url=https://content.instructables.com/FQ4/LLAB/IJP234OQ/FQ4LLABIJP234OQ.jpg&filename=IMG_1987.JPG)
![IMG_1988.JPG](/proxy/?url=https://content.instructables.com/FKM/4AZ8/IJP234OS/FKM4AZ8IJP234OS.jpg&filename=IMG_1988.JPG)
You can easily get all Electronic Components Online in India from DNA Technology
I still give the items you shall be needing
- Arduino Uno(other version will work too)
- DC Siren
- jumpers male to male
- Ultrasonic sensor
- Breadboard
I just showed the breadboard prototype in the instructable, i will be making a case later and shift he circuit in the case.
Circuit
![ultrason_hcsr04_bb.jpg](/proxy/?url=https://content.instructables.com/F71/4KX5/IJP2350L/F714KX5IJP2350L.jpg&filename=ultrason_hcsr04_bb.jpg)
![ultrason_hcsr04_schem.jpg](/proxy/?url=https://content.instructables.com/FIM/S5HO/IJP2350M/FIMS5HOIJP2350M.jpg&filename=ultrason_hcsr04_schem.jpg)
![Fritzing 22-01-2016 174518.jpg](/proxy/?url=https://content.instructables.com/FGJ/6Z5T/IJP235MK/FGJ6Z5TIJP235MK.jpg&filename=Fritzing 22-01-2016 174518.jpg)
![Fritzing 22-01-2016 174639.jpg](/proxy/?url=https://content.instructables.com/FTC/ARMK/IJP235N0/FTCARMKIJP235N0.jpg&filename=Fritzing 22-01-2016 174639.jpg)
![Fritzing 22-01-2016 174320.jpg](/proxy/?url=https://content.instructables.com/F20/8B8X/IJP235NH/F208B8XIJP235NH.jpg&filename=Fritzing 22-01-2016 174320.jpg)
The Circuits are given
The only thing that i need to explain is the Ultrasonic sensor.
HC-Sr04 Ultrasonic Sensor
It is one of the most commonly used distance measuring ultrasonic sensors and works extremely well with Arduino.
This module has 4 pins- Vcc (5V), Trig, Echo, GND. Trig (trigger) is used to send out an ultrasonic high level pulse for at least 10μs and the Echo pin then automatically detects the returning pulse.
How it works ?
The time it takes the sound wave to be sent, hit the object and return back to the sensor is measured. This time is then multiplied by the speed of sound (343m/sec = 0.0343cm/μs = [1/29.1] cm/μs approx.) to give the total distance traveled by the ultrasonic wave, which is then divided by 2 (to account for the fact that the wave was sent, hit the object, and then returned back to the sensor, hence covering twice the distance to the object)Distance = (Time for wave to return * Speed of sound) / 2.
How to Control the Volume of Buzzer Using PWM
![1743519_10202498401301461_4493180708613874287_n.jpg](/proxy/?url=https://content.instructables.com/FBG/U9UC/IJP23F6T/FBGU9UCIJP23F6T.jpg&filename=1743519_10202498401301461_4493180708613874287_n.jpg)
![350px-Delta_PWM.svg.png](/proxy/?url=https://content.instructables.com/FVO/QWHC/IJP23FQZ/FVOQWHCIJP23FQZ.png&filename=350px-Delta_PWM.svg.png)
![688px-PWM,_3-level.svg.png](/proxy/?url=https://content.instructables.com/F7A/DTGX/IJP23FRZ/F7ADTGXIJP23FRZ.png&filename=688px-PWM,_3-level.svg.png)
PWM Stands For Pulse Width Modulation
Analog Signal can be represented in digital world by means of pulse train .In a Pulse Width Modulation we basically represent analog voltage it term of the pulse width. In arduino, we use the analogwrite function to get a PWM wave the function generates a square wave of specified duty cycle the value of which is defined by the user. In the graphic below, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time)
Programming the Arduino
![Fritzing 22-01-2016 173413.jpg](/proxy/?url=https://content.instructables.com/F2E/JMQR/IJP234S3/F2EJMQRIJP234S3.jpg&filename=Fritzing 22-01-2016 173413.jpg)
![Fritzing 22-01-2016 173440.jpg](/proxy/?url=https://content.instructables.com/FE9/CRZ9/IJP234S5/FE9CRZ9IJP234S5.jpg&filename=Fritzing 22-01-2016 173440.jpg)
I searched a lot for the ultrasonic sensor, there was Ping library but it didn't worked for me.
Also there was a newping library
but i went with a simple sketch
int triggerPin = 7; //triggering on pin 7
int echoPin = 8; //echo on pin 8
int siren= 3;
void setup()
{
Serial.begin(9600);
//we'll start serial comunication, so we can see the distance on the serial monitor
pinMode(led, OUTPUT);
pinMode(triggerPin, OUTPUT); //defining pins
pinMode(echoPin, INPUT);
}
void loop()
{
int duration, distance; //Adding duration and distance
digitalWrite(triggerPin, HIGH); //triggering the wave(like blinking an LED)
delay(10); digitalWrite(triggerPin, LOW);
duration = pulseIn(echoPin, HIGH); //a special function for listening and waiting for the wave
distance = (duration / 2) / 29.1; //transforming the number to cm(if you want inches, you have to change the 29.1 with a suitable number
if (distance < 100 )
{
analogWrite(led,75); Serial.print("ON"); //printing the numbers
}
else
{
digitalWrite(led, LOW);
}
Serial.print(distance); //printing the numbers Serial.print("cm"); //and the unit Serial.println(" "); //just printing to a new line
delay(500);
}