Introduction: How to Make a Siren Using Arduino

About: I am pursuing CSE engineering and have enthusiasm in Arduino DIY projects and ROBOTICS.

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

Step 1: Hardware Required

  • Arduino board, I am using an Arduino Uno
  • Solderless breadboard
  • 5 Red and 5 Blue LED
  • Jumper wire
  • Piezo buzzer/Speaker and 100ohm resistor
  • Push button and 10K resistor
  • DC Power supply (9 V Battery)

Step 2: Circuit & Connections

STEP A: ( Connecting LED)

As we basically building a siren so, red and blue flash looks cool. So take 5 red and 5 Blue LEDs. Now, connect the negative terminal of these led's with a 220ohm resistor (current limiting) to the negative rail of the breadboard as shown in the circuit diagram. Positive ends of red leds are connected to pin 3 to pin 7 while the positive ends of Blue leds are connected to pin 8 to pin12 of Arduino's digital pin.

STEP B: (Connecting Piezo Buzzer)

Now, its time to connect our buzzer and the pushButton with the Breadboard. Connect the Piezo buzzer with a 100ohm resistor to the negative rail and positive end of buzzer connected to pin 13.

STEP C: (Connecting pushButton)

Connect one out of four pins of pushButton with pin 2 of and connect down it to GND rail using a pull down resistor of 10k ohm. Connect 5V with another button pin as shown in the circuit diagram.

Step 3: Programming

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.

HOW SYNC WORKS

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:

Let us take three() as an example to understand it.

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

Step 4: Video Tutorial

If It Helps, Please Subscribe