Low-level Triggered Passive Buzzer
Module Source
Purchase Link: https://item.taobao.com/item.htm?abbucket=10&id=610194508058&ns=1&spm=a21n57.1.item.5.4914523cPA58KZ Baidu Netdisk Download Link: https://pan.baidu.com/s/1pjbD2u9hcSW0caC3WUwRIg
Password:cyzk
Specifications
Operating voltage 3.3V-5V
With fixing bolt holes for easy installation
Small board PCB size: 3.3cm * 1.3cm
Hardware Interface
The VCC of the module is connected to the 5V of the development board.
The GND of the module is connected to the GND of the development board.
The I/O of the module is connected to pin 10 of the development board.
Usage Method
c
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 18, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
int buzzer = 10; // 定义连接蜂鸣器的引脚为数字引脚10
// 定义音符的频率
int notes[] = {262, 294, 330, 349, 392, 440, 494};
int noteDuration = 500; // 定义音符持续时间,单位为毫秒
void setup() {
pinMode(buzzer, OUTPUT); // 设置蜂鸣器引脚为输出模式
}
void loop() {
for (int note = 0; note < 7; note++) {
tone(buzzer, notes[], noteDuration); // 播放音符
delay(noteDuration); // 等待音符结束
}
noTone(buzzer); // 停止播放
delay(1000); // 暂停1秒
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Usage Testing
When powered up it will emit a note of a specific frequency.