1.实验器材
Arduino开发板,面包板一块,杜邦线若干,LED灯若干,220欧电阻若干,蜂鸣器一个。
2.实验操作
- 将六个led灯的正极依次接到arduino板I/O接口的2-7口,
- 电源负极依分别接一个220欧的电阻 。
- 整体负极接arduino板的GND接口。
- 蜂鸣器正极接arduino板I/O接口的8口,负极接GND。
3.代码实现
[code]int buzzer=8; //设置控制蜂鸣器的数字 设置控制蜂鸣器的数字 IO脚 int BASE = 2 ; //第一颗 第一颗 LED 接的 I/O 腳 int NUM = 6; //LED 的总数 int song[] = {/* 儿歌《小星星》*/277,277,415,415,466,466,415,370,370,330,330,311,311,277,415,415,370,370,330,330,311,415,415,370,370,330,330,311,277,277,415,415,466,466,415,370,370,330,330,311,311,277,415,415,370,370,330,330,311,415,415,370,370,330,330,311,277,277,415,415,466,466,415,370,370,330,330,311,311,277,};void setup() {for (int thisNote = 0; thisNote |