Arduino - Siren

In this tutorial, we are going to learn how to program Arduino to control a siren to produce a warning sound and/or light.

Hardware Required

1×Arduino UNO or Genuino UNO
1×USB 2.0 cable type A/B
1×Relay
1×12V Alarm Siren Horn
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×(Recommended) Screw Terminal Block Shield for Arduino Uno
1×(Recommended) Breadboard Shield For Arduino Uno
1×(Recommended) Enclosure For Arduino Uno

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Please note: These are Amazon affiliate links. If you buy the components through these links, We will get a commission at no extra cost to you. We appreciate it.

About Siren

Depending on the manufacturer, a siren can produce either a loud sound or a warning light, making it suitable for an alarm system. It is also available in several operating voltages. This tutorial will use a 12V siren, and other voltages will be similar.

Pinout

Arduino 12V siren Pinout

12V siren usually has two pins:

  • Negative (-) pin (black): needs to be connected to GND of DC power supply
  • Positive (+) pin (red): needs to be connected to 12V of DC power supply

How to Control a Siren

If 12V siren is powered by 12V power supply, it make sound and/or warning light. To control a 12V siren, we need to use a relay in between Arduino and 12V siren. Arduino can control the 12V siren via the relay. If you do not know about relay (pinout, how it works, how to program ...), learn about relay in the Arduino - Relay tutorial

Wiring Diagram

Arduino 12V siren Wiring Diagram

This image is created using Fritzing. Click to enlarge image

Arduino Code

The below code repeatedly turns the 12V siren ON in two seconds and OFF in four seconds,

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-siren */ #define RELAY_PIN 4 // the Arduino pin that controls the siren via relay // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin D4 as an output. pinMode(RELAY_PIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(RELAY_PIN, HIGH); // turn on siren 2 seconds delay(2000); digitalWrite(RELAY_PIN, LOW); // turn off siren 5 seconds delay(4000); }

Quick Steps

  • Connect Arduino to PC via USB cable
  • Open Arduino IDE, select the right board and port
  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino
  • Check out the siren's state

Code Explanation

Read the line-by-line explanation in comment lines of code!

Video Tutorial

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.

The Best Arduino Starter Kit

※ OUR MESSAGES