SKU:U132












Unit Buzzer 是一款 无源蜂鸣器 拓展单元,采用 4KHz 频率信号驱动。额定电压供电情况下,10cm 内声压等级可达 72dB,具有体积小巧、功耗低、发声效果好、自带保护外壳等特点,适用于各类蜂鸣报警场景。
| 规格 | 参数 | 
|---|---|
| 驱动频率 | 4KHz 1/2duty 方波 | 
| 功耗 | 5V@86mA | 
| 产品尺寸 | 24.0 x 24.0 x 8.0mm | 
| 产品重量 | 3.3g | 
| 包装尺寸 | 138.0 x 93.0 x 9.0mm | 
| 毛重 | 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.  将指定通道绑定到指定 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);
}