2012年12月4日 星期二
week13,hw11
程式碼
int buttonPin = 2;
int buttonPin3 = 3;
int buttonPin4 = 4;
int buttonPin5 = 5;
int buttonPin6 = 6;
int buttonState = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;
int buttonState6 = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
pinMode(buttonPin6, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
buttonState5 = digitalRead(buttonPin5);
buttonState6 = digitalRead(buttonPin6);
if (buttonState == HIGH) {
tone(8, 262, 10);
}
if (buttonState3== HIGH) {
tone(8, 294, 10);
}
if (buttonState4 == HIGH) {
tone(8, 330, 10);
}
if (buttonState5 == HIGH) {
tone(8, 349, 10);
}
if (buttonState6 == HIGH) {
tone(8, 392, 10);
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言