【笔记】Arduino控制无源蜂鸣器模块

前言

Arduino UNO R4控制无源蜂鸣器模块

传送门

接线图

  • 低电平发声
flowchart LR
  subgraph UNO ["Arduino UNO R4"]
    Pin_7(("7"))
    Pin_3V3(("3V3"))
    Pin_GND(("GND"))
  end

  subgraph Module ["无源蜂鸣器模块"]
    A(("GND"))
    B(("I/O"))
    C(("VCC"))
  end

  Pin_7 --- B
  Pin_3V3 --- C
  Pin_GND --- A

源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const int PIN = 7;

void setup()
{
pinMode(PIN, OUTPUT);
}

void loop()
{
tone(PIN, 523);
delay(400);
tone(PIN, 587);
delay(400);
tone(PIN, 659);
delay(400);
}

完成

参考文献

哔哩哔哩——创乐博智能科技