How To Make A Siren Using Arduino
How To Make A Siren Using Arduino
by Jigneshk5
My project is a button controlled Siren with different LED transitions. You can change the Siren sound( eg. police
or ambulance siren etc.) for each press. I have added 2 different led patterns for each siren using 10 LEDs. I have
added a total of 4 Siren tones. You can checkout the Arduino code and the Explanation here:
https://youtu.be/Q22AfdbFTq8
Solderless breadboard
Jumper wire
STEP A: ( Connecting LED) Now, its time to connect our buzzer and the
pushButton with the Breadboard. Connect the Piezo
As we basically building a siren so, red and blue flash buzzer with a 100ohm resistor to the negative rail and
looks cool. So take 5 red and 5 Blue LEDs. Now, positive end of buzzer connected to pin 13.
connect the negative terminal of these led's with a
220ohm resistor (current limiting) to the negative rail STEP C: (Connecting pushButton)
of the breadboard as shown in the circuit diagram.
Positive ends of red leds are connected to pin 3 to pin Connect one out of four pins of pushButton with pin 2
7 while the positive ends of Blue leds are connected of and connect down it to GND rail using a pull down
to pin 8 to pin12 of Arduino's digital pin. resistor of 10k ohm. Connect 5V with another button
pin as shown in the circuit diagram.
STEP B: (Connecting Piezo Buzzer)
1. Since we are using button press to switch between the tones so we have to remove the problem of button
debouncing, which I removed by software implemention using a boolean Debounce function.
2. The conditional if else is used after it for Switching between different functions.Here one() and oneA() are for 1st
tone with two different led transition, similar for other functions too. And the tones for each function is synced with
led transition using delay() appropriately.
tone() uses one of the builtin timer on the arduino and that timer operates independently of the delay(). Or In other
words we can say that if you want to play distict beats, you should check the difference between the delay time
and duration of tone() as both the function are working parallel. Now what I did is that divide the delay in smaller
parts to use it with different sets of Leds. If you want a video tutorial on this. Check this out:
//www.youtube.com/embed/1_LMAgO14z0
void three() { //This function produces the 3rd siren (AMBULANCE sound).<br>tone(buzz,440,200);
<p>delay(300);<br>for(int i=3;i<=6;i++)
digitalWrite(i,HIGH);
noTone(buzz);
tone(buzz,494,500);
delay(300);
for(int i=3;i<=6;i++)
{ digitalWrite(i,LOW);
digitalWrite(i+6,HIGH); }
noTone(buzz);
tone(buzz,523,300);
delay(200);
digitalWrite(7,HIGH);
delay(50);
digitalWrite(8,HIGH);
delay(50);
noTone(buzz);
}</p>
After the last tone()...I divided the delay of 300ms into 200,50 and 50 so that the led at pin 7 and 8 have a blinking
effect at the end of 523hz tone while the tone is continuous in the background for 300ms ( Since there is no
difference between delay and tone duration as explained above).
Here is the complete code of my project.Now it's your turn to make some cool tone using my Project and explore
all the possibilities.
https://github.com/jigneshk5/Siren-Code-Arduino
//www.youtube.com/embed/Q22AfdbFTq8
Great Arduino tutorial. Projects like this are great for teaching the basics on output pin controls.
Thaks Bro..