Note
Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
Learn & Share: Exchange tips and tutorials to enhance your skills.
Exclusive Previews: Get early access to new product announcements and sneak peeks.
Special Discounts: Enjoy exclusive discounts on our newest products.
Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
👉 Ready to explore and create with us? Click [here] and join today!
Active Buzzer
Overview
The active buzzer is a typical digital output device that is as easy to use as lighting up an LED!
Two types of buzzers are included in the kit. We need to use active buzzer. Turn them around, the sealed back (not the exposed PCB) is the one we want.
Required Components
In this project, we need the following components.
It’s definitely convenient to buy a whole kit, here’s the link:
Name |
ITEMS IN THIS KIT |
LINK |
|---|---|---|
Elite Explorer Kit |
300+ |
You can also buy them separately from the links below.
COMPONENT INTRODUCTION |
PURCHASE LINK |
|---|---|
- |
|
- |
Wiring
Note
When connecting the buzzer, make sure to check its pins. The longer pin is the anode and the shorter one is the cathode. It’s important not to mix them up, as doing so will prevent the buzzer from producing any sound.
Schematic Diagram
Code
Note
You can open the file
16-active_buzzer.inounder the path ofelite-explorer-kit-main\basic_project\16-active_buzzerdirectly.Or copy this code into Arduino IDE.
1/*
2 This code controls an active buzzer connected to pin 8 on an Arduino Uno R4.
3 The buzzer will be turned on for 1 second and then turned off for 1 second, continuously.
4
5 Board: Arduino Uno R4
6 Component: Active Buzzer
7*/
8
9// Declare the pin where the buzzer is connected
10const int buzzerPin = 8;
11
12// Initialize the pin as an output
13void setup() {
14 pinMode(buzzerPin, OUTPUT);
15}
16
17// Main loop
18void loop() {
19 digitalWrite(buzzerPin, HIGH); // Turn the active buzzer on
20 delay(1000); // Wait for 1 second
21 digitalWrite(buzzerPin, LOW); // Turn the active buzzer off
22 delay(1000); // Wait for 1 second
23}
After the code is uploaded successfully, you will hear a beep every second.