diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 1613dc1..ca4d952 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -376,16 +376,22 @@ int getLightchirp() { void wipeEEPROM() { - // i is helper variable. We reuse it later here again. + // i is helper variable. We use it in this function multiple times. + // when doing this, ensure every time to set i to 0 again before reusing byte i = 0; + + + Serial.println(":: wipe EEPROM ::"); + while(digitalRead(PIN_WIPE) == LOW ) { // only show the Serial message once if(i == 0) { Serial.println("Please release PIN_WIPE to erase all data saved in EEPROM"); - Serial.println("LAST CHANCE TO KEEP THE DATA WHEN RESETTING NOW!!"); + Serial.println("LAST CHANCE TO KEEP THE DATA BY RESETTING NOW!!"); + // increase i to show the serial message only once + i = 1; } - // increase i to show the serial message only once - i = 1; + delay(500); } // write a 0 to all 512 bytes of the EEPROM @@ -535,7 +541,6 @@ void setup() { // when PIN_WIPE is set to LOW, wipe EEPROM if(digitalRead(PIN_WIPE) == LOW) { - Serial.print("PIN_WIPE (D4) is set to LOW, wiping EEPROM now.."); // wipe EEPROM wipeEEPROM(); }