6289浏览
查看: 6289|回复: 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
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail