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
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
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
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
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.
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.