Introduction: World's Loudest Arduino Intruder Alarm

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

Step 1: Items

You can easily get all Electronic Components Online in India from DNA Technology

I still give the items you shall be needing

I just showed the breadboard prototype in the instructable, i will be making a case later and shift he circuit in the case.

Step 2: Circuit

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.

Step 3: How to Control the Volume of Buzzer Using PWM

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)

Step 4: Programming the Arduino

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);

}

Comments

author
BunceyTheInbred made it!(author)2016-02-02

I'm using NewPing and yet all my results in the monitor are 0cm

author
panigrc made it!(author)2016-01-27

Hi, I am using a transistor (a general one 2N2222) to drive the buzzer from 12V source which makes it a lot louder ;)

author
geekrex made it!(author)2016-01-28

ya it will be but too much loud can't get you out of your society in india so i had to lower the volume a bit

author
Jedimaster0 made it!(author)2016-01-23

Just a thought, I found the code for the ping at: https://www.arduino.cc/en/Tutorial/Ping
I noticed that your in your ping section, you have a (high, low, high) ping. However, from what I have been reading, it's supposed to be a (low, high, low) ping to ensure a clean response. When I built a similar project, I wrote my code like I described and have had good results. I can get a range of 120in or so with consistent results. I'm just wondering if your sensor is different in some way or if you are understanding something I'm not; which is a good possiblility.

author
geekrex made it!(author)2016-01-23

Actually you are right , but the ping didn't work for me
i was finding option on the internet , and i found this on the internet ,and this worked greatly in my module,

author
geekrex made it!(author)2016-01-23

If you download the new ping library for the sensor you can see their is this high-low-high

http://playground.arduino.cc/Code/NewPing

author
Slk_Stephane made it!(author)2016-01-23

Superb!

author
geekrex made it!(author)2016-01-23

Thanks

author
kavish+laxkar made it!(author)2016-01-23

another one...its cool.:)

author
geekrex made it!(author)2016-01-23

thanks Kavish

About This Instructable

6,141views

138favorites

License:

Bio: So basically i am a crazy person, who loves to think the most odd way ever possible,who makes what he thinks and also let ... More »
More by geekrex:$200 DIY 3D Printer Build$1 DIY Fidget ToyHow to Make a DC Motor Speed Controller
Add instructable to: