7598| 0
|
[入门] 这是我的课堂(4)——电子钢琴 |
这次我们来做一个电子钢琴 认识按钮与音响的结合 [mw_shl_code=applescript,true]#define C 523 #define D 587 #define E 659 #define G 698 #define A 784 const int yin=9; const int BC=7; const int BD=6; const int BE=5; const int BG=4; const int BA=3; void setup() { // put your setup code here, to run once: } void loop() { while(digitalRead(BC)) tone(yin,C); while(digitalRead (BD)) tone(yin,D); while(digitalRead(BE)) tone(yin,E); while(digitalRead(BG)) tone(yin,G); while(digitalRead(BA)) tone(yin,A); noTone(yin);// put your main code here, to run repeatedly: } [/mw_shl_code] 由于时间关系这里不多说 接线如下 音响=9 按钮分别=7 6 5 4 3 |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed