2012年12月4日 星期二

98160860黃麒, 98163021張耀璇, HW11, Week13,

int inpin1=3;
int inpin2=4;
int inpin3=5;
int inpin4=6;
int inpin5=7;

int buttonState1 = 0; // variable for reading the pushbutton status
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 == HIGHtone(8, 524,4);
  else if (buttonState2 == HIGHtone(8, 588,4);
  else if (buttonState3 == HIGHtone(8, 660,4);
  else if (buttonState4 == HIGHtone(8, 698,4);
  else if (buttonState5 == HIGHtone(8, 784,4);
  else {
  noTone(8);
  }
}

沒有留言:

張貼留言