I'm creating a Temperature logging device with thermocouple K and SD card breakout and a RGB LCD Shield Kit w/ 16x2 Character Display (with buttons).
Everything runs ok: temperature displaying on the LCD and logging on txt file on the micro SD card work well
Now I try to configure button on the shield
- button UP to reset measurements and timer , it works
button Down to pause measurements, then when pushed again, continue measurements. I don't know how to do that (how to go out the while condition).
if (buttons) { if (buttons & BUTTON_UP) { lcd.clear(); lcd.print("RESET "); if (SD.exists("datalog.txt")) { SD.remove("datalog.txt"); File dataFile = SD.open("datalog.txt", FILE_WRITE); } else { // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. File dataFile = SD.open("datalog.txt", FILE_WRITE); // if the file is available, write to it: } StartTime = millis(); delay(500); } if (buttons & BUTTON_DOWN) { lcd.clear(); lcd.print("STOP"); while (buttons & BUTTON_DOWN){ ; }
}
I already thank you for your help,
Vincent
if
statements .... why are you testingbuttons
in the secondif
statement? .... you already tested it in the firstif
statement .... same with the lastif
statement ..... also, check thewhile (buttons & BUTTON_DOWN){
statement at the bottom ..... do you think that the values ofbuttons
andBUTTON_DOWN
will ever change? .... if you think that they will change, then what changes them?