19. void loop() {
bool b1 = digitalRead(SW); //讀取開關目前狀態
if (b1 != lastState) { //開關狀態改變
delay(20); //防彈跳
if (b1 == digitalRead(SW)) { //再次確認開關狀態
laststate = b1;
click++;
}
}
if (click = 2){ //檢查是否已Click開關
click = 0;
Serial.print(msg2);
Serial.println(msg1);
for (char i = 0; i < 255; i += 5) {
analogWrite(LED, i);
delay(100);
}
analogWrite(LED, 0);
}
}
Lab 使用Serial Monitor除錯 3/5
19
20. debug_exercise:4:1: error: missing terminating " character
char msg2[] = "Hello, ;
^
debug_exercise:5:6: error: expected primary-expression before 'click'
byte click = 0;
^
debug_exercise:6:18: error: 'high' was not declared in this scope
bool lastState = high;
^
D:clouding storageMeganotesarduinocodedebug_exercisedebug_exercise.ino: In function
'void setup()':
debug_exercise:9:11: error: 'sw' was not declared in this scope
pinMode(sw, INPUT_PULLUP);
^
D:clouding storageMeganotesarduinocodedebug_exercisedebug_exercise.ino: In function
'void loop()':
debug_exercise:18:7: error: 'laststate' was not declared in this scope
laststate = b1;
^
debug_exercise:19:7: error: 'click' was not declared in this scope
click++;
^
debug_exercise:22:7: error: 'click' was not declared in this scope
if (click = 2){ //已Click開關
^
Lab 使用Serial Monitor除錯 4/5
20