本站改版新增arduino频道
arduino arduino 蜂鸣器
const int buzzerPin = 18; // 定义蜂鸣器连接的引脚
void setup() {
pinMode(buzzerPin, OUTPUT); // 设置蜂鸣器引脚为输出模式
}
void loop() {
// 发出声音
tone(buzzerPin, 1000); // 在蜂鸣器引脚上产生1kHz的音调
delay(1000); // 持续1秒
// 停止声音
noTone(buzzerPin); // 停止蜂鸣器发声
delay(1000); // 等待1秒
}
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.009321928024292 seconds