1. 瑪莉有隻小綿羊
2.我們的厲害樂譜
3212333 222 355
3212333 22321
3345 5432 1123 322
3345 5432 1123 211
3. 程式碼
int buttonPin2 = 2;
int buttonPin3 = 3;
int buttonPin4 = 4;
int buttonPin5 = 5;
int buttonPin6 = 6;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;
int buttonState6 = 0;
void setup() {
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
pinMode(buttonPin6, INPUT);
Serial.begin(9600);
}
void loop() {
buttonState2 = digitalRead(buttonPin2);
buttonState3= digitalRead(buttonPin3);
buttonState4= digitalRead(buttonPin4);
buttonState5 = digitalRead(buttonPin5);
buttonState6 = digitalRead(buttonPin6);
if (buttonState2 == HIGH) {
Serial.println("Start Playing");
tone(8, 262, 10);
}
if (buttonState3 == HIGH) {
Serial.println("Start Playing");
tone(8, 294, 10);
}
if (buttonState4 == HIGH) {
Serial.println("Start Playing");
tone(8, 330, 10);
}
if (buttonState5 == HIGH) {
Serial.println("Start Playing");
tone(8, 349, 10);
}
if (buttonState6 == HIGH) {
Serial.println("Start Playing");
tone(8, 392, 10);
}
}
4.這次的arduino我覺得超酷超有趣的,但是在接線時有點複雜,不過我們還是突破了,所以我們超有成就感,自己做出一座簡易鋼琴的感覺超妙的,讓我回憶起高中時作詞作曲的歲月,所以繼續加油吧 大家!
沒有留言:
張貼留言