Product Introduction #
Buzzer module is an integrated structure of sound electronic components, using DC power supply, widely used in toys, alarms and other electronic products. Buzzer is divided into passive buzzer and active buzzer; There is no shock source inside the passive buzzer, and it needs to be driven by 2K~5K square wave. Passive buzzer can freely control the output sound frequency, and can be programmed to write different scales and duration time to synthesize a beautiful melody of music.
Parameter Specification #
Parameters | Value/Description |
Operating voltage | 3.3~5V |
Operating temperature | -20°C~+70°C |
Output signal | Digital signal |
Size | 3.16cm*2.38cm |
Wiring Diagram #
Note:Expansion board is attached to esp32 controller board.
P-Buzzer Module | ESP32 |
VCC | 5V |
GND | GND |
Sign | Pin 32 |
Sample Code #
int buzzerPin=32;//Define the buzzer pin
#define C4 262
#define D4 294
#define E4 330
#define F4 350
#define G4 393
#define A4 441
#define B4 495
int length0=14;
int tune0[] = { C4, C4, G4, G4, A4, A4, G4, F4, F4, E4, E4, D4, D4, C4 };
float durt0[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2 };
void setup(){
for (int x = 0; x < length0; x++) {
tone(buzzerPin, tune0[x]);
delay(500 * durt0[x]);
noTone(buzzerPin);
delay(30);
}
}
void loop(){
}
Note: If you are using an Arduino board, then change the pin in the program to PIN7, and then connect the hardware pin to PIN7 and upload the program.
Test Result #
After you upload the code to the controller board, the buzzer will emit a piece of music, and you can change the tune to play different music.
Related Resources #
Get One Now #
B2B Business: info@acebott.com