I'm having some trouble with my LCD's text becoming corrupted. it only seems to happen when I press a button wired to digital pin 9 repeatedly. below is the only section of my code that changes the LCD in any way. pressing the button flips the 'light' var true/false
Here's what I mean by 'becoming corrupted':
if(timers[3] < timers[1]){ //refresh screen on timer
timers[3] = timers[1] + scrRefresh; //scrRefresh = 1000 timers[1] = millis()
lcd.clear(); //update temp info (line 1)
lcd.setCursor(3, 0);
lcd.print(temp); //int
lcd.print("c");
lcd.setCursor(9, 0);
lcd.print(on); //byte
lcd.print("-");
lcd.print(off); //byte
if(!pause){ //update line 2
lcd.setCursor(0, 1);
lcd.print("State: ");
lcd.setCursor(7, 1);
if(state) lcd.print("On");
else lcd.print("Off");
}
else{
lcd.setCursor(0, 1);
lcd.print("Paused: ");
if((timers[2] - timers[1]) > 60000){ // paused and pause timer greater than 1min?
int minutes = (timers[2] - timers[1]) / 1000 / 60;
int seconds = ((timers[2] - timers[1]) / 1000) - minutes * 60;
lcd.setCursor(8, 1);
lcd.print(minutes);
lcd.print("m");
lcd.print(seconds);
lcd.print("s");
}
else{
lcd.setCursor(8, 1);
lcd.print(int((timers[2] - timers[1]) / 1000));
lcd.print("s");
}
}
lcd.setCursor(15,1);
if(light) lcd.print("."); //light indicator
}