完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
相关推荐
1个回答
|
|
Arduino演奏the truth that you leave
利用Arduino及配套的蜂鸣器等,可以实现音乐的演奏。由于本人水平所限,该视频仅仅截取了原曲的一部分,而且音调有偏差的地方,还请多多包涵! 视频 Arduino-The Truth that You Leave 代码: #include #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,0,9,0,12,12,12,12,9,9,9,0,12,12,12,12,9,10,11,0,10,0,0,10,0,0,0,12,12,12,12,9,9,9,0,12,12,12,12,9,10,11,0,12,0,0,9,10,11,0,0 ,6,7,8,12,0,0,11,10,9,0,0,10,11,10,0,9,0,8,0,0,0,12,12,12,12,9,9,9,0,12,12,12,12,9,10,11,0,10,0,10,13,14,15,0,0,0,19,19,19,19,16,16,16,0,19,19,19,19,16,17,18,0, 17,0,10,13,13,14,15,14,13,10,8,9,0,19,19,19,19,16,16,16,0,19,19,19,19,16,17,18,0,19,19,19,0,17,0,18,17,13,14,15,19,19,0,0,18,17,16,0,16,0,0,21,0,17,16,16,17,16,0,15,15,0,19,19,19,19, 16,16,16,0,19,19,19,19,16,17,19,0,20,0,8,10,13,15,17,20,0,0,0,0,0,10,9,8,7,8,0,0,8,8,9,0,0,10,9,8,7,8,0,0,8,8,3,0,0,10,9,8,7,8,0,0,8,9,0,12,0,10,0,12,0,0,0,10,9,8,7,8,0,0,8,0,9,0,0,10,9,8,7,8,0,0,8,0,3,0,0,10,9,8,7,8,0,0,8,0,12,0,10,0,12,0,0,0,0,0, 12,12,0,8,8,0,12,12,0,9,9,0,8,9,10,10,10,0,9,8,10,12,12,0,0,12,12,0,8,8,0,12,12,0,9,9,0,7,8,9,10,10,10,15,14,12,0,0,12,12,0,8,8,0,12,12,0,9,9,8,9,8,0,0,9,12,12,0,8,8,0,12,12,0,9,9,8,9,8,0,0,0,0,0,0}; //以数组的形式存放歌曲音调 void setup() { pinMode(pin,OUTPUT); lcd.init();//初始化LCD lcd.backlight(); //点亮LCD背光灯 lcd.setCursor(1, 0);//调整光标位置为第0行(即物理上的第1行)第1列(下同) lcd.print("the truth that");//输出相应的文字 lcd.setCursor(4, 1); lcd.print("you leave"); delay(5000); lcd.clear();//清屏 lcd.setCursor(3, 0); lcd.print("by Pianoboy"); delay(5000); lcd.clear(); lcd.print("Give me a like!"); } void loop() { for(int i=0;i<425;i++) { if(song!=0) { tone(pin,scale[song-1]); //播放对应的音调,原型为tone(输出管脚,频率(Hz)) } else { noTone(pin);//终止播放 } delay(120); noTone(pin); delay(60); } Display(); delay(5000); } void Display() { lcd.clear(); lcd.setCursor(3,0); lcd.print("Thank you!"); delay(5000); lcd.clear(); } |
|
|
|
只有小组成员才能发言,加入小组>>
3278 浏览 9 评论
2955 浏览 16 评论
3455 浏览 1 评论
8987 浏览 16 评论
4050 浏览 18 评论
1102浏览 3评论
570浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
568浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2301浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1857浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 04:16 , Processed in 1.005632 second(s), Total 80, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号