Arduino UNO R4 - Buzzer

In this guide, we will learn to program the Arduino UNO R4 to make a 12V active buzzer sound loudly. If you need to manage a 5V active or passive buzzer, you can read our Arduino UNO R4 Piezo Buzzer tutorial.

Hardware Preparation

1×Arduino UNO R4 WiFi
1×Arduino UNO R4 Minima (Alternatively)
1×USB Cable Type-C
1×Relay
1×12V Active Buzzer
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×(Recommended) Screw Terminal Block Shield for Arduino UNO R4
1×(Recommended) Breadboard Shield For Arduino UNO R4
1×(Recommended) Enclosure For Arduino UNO R4

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 12V Active Buzzer

The 12V Active Buzzer makes a loud noise, good for alarm systems.

Pinout

Arduino UNO R4 12V Active Buzzer Pinout

A 12V active buzzer typically has two pins.

  • Connect the negative (-) pin (black) to the GND of the DC power supply.
  • Connect the positive (+) pin (red) to the 12V of the DC power supply.

How to Control 12V Active Buzzer

When a 12V active buzzer uses a 12V power supply, it produces a sound. To operate a 12V active buzzer with an Arduino UNO R4, connect a relay between them. The Arduino UNO R4 can control the buzzer through this relay. If you are unfamiliar with relays (their pinout, function, or programming), refer to the relay tutorial for Arduino UNO R4 here.

Wiring Diagram

The wiring diagram between Arduino UNO R4 12V Active Buzzer

This image is created using Fritzing. Click to enlarge image

Arduino UNO R4 Code

The code makes the 12V buzzer turn ON for two seconds and OFF for five seconds repeatedly.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-buzzer */ #define RELAY_PIN 3 // The Arduino UNO R4 pin that controls the buzzer 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 buzzer 2 seconds delay(2000); digitalWrite(RELAY_PIN, LOW); // turn off buzzer 5 seconds delay(5000); }

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Wire the components according to the provided diagram.
  • Connect the Arduino Uno R4 board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
  • Copy the provided code into the Arduino IDE
  • Press the Upload button in the Arduino IDE to transfer the code to your Arduino UNO R4
  • Listen to the sound generated by the 12V active buzzer

Code Explanation

You can find the explanation in the comments section of the Arduino code above.

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!