SKU:U132
Passive Buzzer Unit is a mini passive buzzer unit, drove by 4KHz signal, that sounds up to 72dB within 10cm distance under rating input power. With the feature of compact size, low-power consumption, awesome audio performance, and a protective housing. Applied for varied buzzer alarm scenario.
Specifications | Parameters |
---|---|
Drive frequency | 4KHz 1/2duty square wave |
Power consumption | 5V@86mA |
Net weight | 3.5g |
Gross weight | 8.5g |
Product size | 24 * 24 * 8mm |
Packing size | 93 * 138mm |
M5CORE - PORT B | G26 |
---|---|
BUZZER | 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. 将指定通道绑定到指定 IO 口上以实现输出
ledcWrite(ledChannel, 512); //Output PWM. 输出PWM
}
void loop() {
ledcWrite(ledChannel, 512); //Output PWM. 输出PWM
delay(3000);
ledcWrite(ledChannel, 0); //Output PWM. 输出PWM
delay(3000);
}