这是我的课堂(4)——电子钢琴
http://v.youku.com/v_show/id_XMzE2NTg4MTc2NA==.html这次我们来做一个电子钢琴
认识按钮与音响的结合
#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:
}
由于时间关系这里不多说
接线如下
音响=9
按钮分别=7 6 5 4 3
页:
[1]