SKU:U132
Unit Buzzer is a passive buzzer expansion unit, driven by a 4KHz frequency signal. When powered at the rated voltage, the sound pressure level can reach 72dB within 10cm. It is characterized by its compact size, low power consumption, good sound effect, and built-in protective casing, making it suitable for various buzzer alarm scenarios.
Specification | Parameter |
---|---|
Drive Frequency | 4KHz 1/2 duty square wave |
Power Consumption | 5V@86mA |
Product Size | 24.0 x 24.0 x 8.0mm |
Product Weight | 3.3g |
Package Size | 138.0 x 93.0 x 9.0mm |
Gross Weight | 6.8g |
HY2.0-4P | Black | Red | Yellow | White |
---|---|---|---|---|
PORT.B | GND | 5V | Signal | / |
#include <Arduino.h>
#define buzzer_pin 26
int freq = 4000;
int ledChannel = 0;
int resolution = 10;
void setup() {
ledcSetup(ledChannel, freq, resolution); //Sets the frequency and number of counts corresponding to the channel.
ledcAttachPin(buzzer_pin, ledChannel); //Binds the specified channel to the specified I/O port for output.
ledcWrite(ledChannel, 512); //Output PWM.
}
void loop() {
ledcWrite(ledChannel, 512); //Output PWM.
delay(3000);
ledcWrite(ledChannel, 0); //Output PWM.
delay(3000);
}