int inpin1=6;
int inpin2=7;
int inpin3=9;
int inpin4=3;
int inpin5=1;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;
void setup() {
pinMode(inpin1, INPUT);
pinMode(inpin2, INPUT);
pinMode(inpin3, INPUT);
pinMode(inpin4, INPUT);
pinMode(inpin5, INPUT);
}
void loop() {
buttonState1 = digitalRead(inpin1);
buttonState2 = digitalRead(inpin2);
buttonState3 = digitalRead(inpin3);
buttonState4 = digitalRead(inpin4);
buttonState5 = digitalRead(inpin5);
if (buttonState1 == HIGH) tone(8, 524,4);
else if (buttonState2 == HIGH) tone(8, 588,4);
else if (buttonState3 == HIGH) tone(8, 660,4);
else if (buttonState4 == HIGH) tone(8, 698,4);
else if (buttonState5 == HIGH) tone(8, 784,4);
else {
noTone(9);
}
}
2.影片
沒有留言:
張貼留言