Arduino Nano 33 IoT - Siren

In this guide, we will learn how to use the Arduino Nano 33 IoT to control a siren that makes a warning sound and/or light.

Arduino Nano 33 IoT 12V siren

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×Relay
1×12V Alarm Siren Horn
1×12V Power Adapter
1×Optionally, DC Power Jack
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of Siren

Depending on the maker, a siren may make a loud noise or show a warning light, so it works well in an alarm system. It also works with different power levels. In this lesson, we will use a 12V siren, but the other power options work in much the same way.

Pinout

Arduino Nano 33 IoT 12V siren Pinout

A 12-volt siren normally has two metal connectors.

  • Black wire (negative): connect this to the GND (ground) terminal on the DC power source.
  • Red wire (positive): connect this to the 12V terminal on the DC power source.

How to Control a Siren

If you connect a 12V siren to a 12V power source, it will make noise or flash a warning light. To control this siren with an Arduino Nano 33 IoT, you need to use a relay between the Arduino and the siren. The Arduino can then turn the siren on and off through the relay. If you are not familiar with relays (their pins, how they work, how to program them, etc.), please check out the Arduino Nano 33 IoT - Relay tutorial.

Wiring Diagram

The wiring diagram between Arduino Nano and 33 IoT 12V siren

This image is created using Fritzing. Click to enlarge image

Arduino Nano 33 IoT Code

The code below continuously switches a 12V siren on for three seconds and off for five seconds.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-siren */ #define RELAY_PIN 2 // The Arduino Nano 33 IoT that controls the siren via relay // The setup function runs once on reset or power-up void setup() { // initialize digital pin as an output. pinMode(RELAY_PIN, OUTPUT); } void loop() { digitalWrite(RELAY_PIN, HIGH); delay(3000); digitalWrite(RELAY_PIN, LOW); delay(5000); }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Copy the code above and open it in the Arduino IDE.
  • Click the Upload button in the Arduino IDE to send the code to your Arduino Nano 33 IoT.
  • Check the siren to see if it is working.

Code Explanation

Please check the comments in the Arduino code above for the explanation.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!