int buttonPin2 = 3;
int buttonPin3 = 4;
int buttonPin4 = 5;
int buttonPin5 = 6;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;
int speakerPin = 9;
void setup() {
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
}
void loop(){
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
buttonState5 = digitalRead(buttonPin5);
if (buttonState1 == HIGH) {
tone(9, 262,100);
}
else { }
if (buttonState2 == HIGH) {
tone(9, 294,100);
}
else { }
if (buttonState3 == HIGH) {
tone(9, 330,100);
}
else { }
if (buttonState4 == HIGH) {
tone(9, 349,100);
}
else { }
if (buttonState5 == HIGH) {
tone(9, 392,100);
}
else { }
}
沒有留言:
張貼留言