Arduino演奏the truth that you leave
利用Arduino及配套的蜂鸣器等,可以实现音乐的演奏。由于本人水平所限,该视频仅仅截取了原曲的一部分,而且音调有偏差的地方,还请多多包涵!
视频
Arduino-The Truth that You Leave
头文件下载地址:
https://github.com/johnrickman/LiquidCrystal_I2C
代码:
#include<LiquidCrystal_I2C.h>
#define Do0 262
#define Re0 294
#define Mi0 330
#define Fa0 349
#define Sol0 395
#define La0 440
#define Si0 494
#define Do1 523
#define Re1 587
#define Mi1 659
#define Fa1 698
#define Sol1 784
#define La1 880
#define Si1 988
#define Do2 1046
#define Re2 1175
#define Mi2 1318
#define Fa2 1397
#define Sol2 1568
#define La2 1760
#define Si2 1976
//各个声调的频率
LiquidCrystal_I2C lcd(0x27, 16, 2);//初始化LCD
int pin=3; //自行选择作为输出的接口
int scale[]={
Do0,Re0,Mi0,Fa0,Sol0,La0,Si0,Do1,Re1,Mi1,Fa1,Sol1,La1,Si1,Do2,Re2,Mi2,Fa2,Sol2,La2,Si2};
//定义音调数组
int song[]={
12,6,8,12,0,6,8,12,0,6,8,12,0,6,0,8,0,8,0,8,0,8,8,0,8,0,9,0,10,0,11,0,13,19,13,15,19,0,
13,15,19,0,13,17,18,0,19,0,19,0,9,