How to Make a Siren Using Arduino

How to Make a Siren Using Arduino © GPL3+

My project is a button controlled siren with different LED transitions. You can change the siren sound with each press.

  • 5,182 views
  • 4 comments
  • 11 respects

Components and supplies

About this project

My project is a button controlled Siren with different LED transitions. You can change the siren sound (e.g. 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:

Code Explained

1. Since we are using a button press to switch between the tones, 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 to switch between different functions. Here one() and oneA() are for the first tone with two different LED transitions, similarly for other functions, too. And the tones for each function is synced with LED transitions 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 district beats, you should check the difference between the delay time and duration of tone() as both these functions are working parallel. Now what I did is divide the delay into 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).tone(buzz,440,200);
delay(300);
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);
}

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

Code

Schematics

Hardware Required
2018 17 02 16 19 02 oqrordedwj
Circuit & Connections
STEP A: (Connecting LED)

As we are basically building a siren, red and blue flashes look cool. So take 5 red and 5 blue LEDs. Now, connect the negative terminal of these LEDs with a 220 ohm 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 pin 12 of Arduino's digital pin.

STEP B: (Connecting Piezo Buzzer)

Now, it's time to connect our buzzer and the pushButton to the breadboard. Connect the Piezo buzzer with a 100 ohm 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 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.
Project1 bb uovd9pv5b1

Comments

Similar projects you might like

Electronic Piano Keyboard With Preset Songs

Project tutorial by Lindsay Fox

  • 77,973 views
  • 60 comments
  • 150 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 49,797 views
  • 65 comments
  • 146 respects

Arduino Simple "Camera Slider" Electronics

Project tutorial by Ian Cumming

  • 6,840 views
  • 3 comments
  • 18 respects

How to Use Modbus with Arduino

Project tutorial by hwhardsoft

  • 5,340 views
  • 2 comments
  • 14 respects

Electronic Playground With Arduino and Scratch 2

Project tutorial by MJRoBot

  • 4,436 views
  • 0 comments
  • 16 respects

Beepee Boopee Buzz Buzz

Project showcase by MarcusDeLUCa

  • 735 views
  • 3 comments
  • 3 respects
Add projectSign up / Login