0
爲什麼此代碼不起作用? 我在http://www.codebender.cc上運行這個Arduino代碼,它不會在我的Arduino Uno上運行。當我在串行監視器上運行時沒有打印出來,我完全不知道爲什麼? 看看...爲什麼這個Arduino代碼不起作用?
const int button1 = 8;
const int button2 = 9;
const int button3 = 10;
int ison1 = 0;
int ison2 = 0;
int ison3 = 0;
int x = 1;
int y = 1;
int z = 1;
void setup()
{
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
}
void go()
{
Serial.print("Press button 1 (Furthest to the right)...");
while (x == 1){
ison1 = digitalRead(button1);
if (ison1 == HIGH){
Serial.print("Well done!");
x = 2;
}
}
Serial.print("Press button 2 (The middle one)...");
while (y == 1){
ison2 = digitalRead(button2);
if (ison2 == HIGH){
Serial.print("Well done!");
y = 2;
}
}
Serial.print("Press button 3 (Furthest to the left)...");
while (z == 1){
ison3 = digitalRead(button3);
if (ison3 == HIGH){
Serial.print("Well done!");
z = 2;
}
}
Serial.print("You have completed the test!");
}
void loop()
{
delay(5000);
go();
exit(0);
}
你永遠不會按一個按鈕? –