I've pasted the relevant part of my code below. The DoControl command is part of the PID library. Every ten seconds, I command it to log the input, and output in percent to the screen. However, it will often display random symbols, scroll these random symbols, and make it impossible to interface with the screen. However, it will often return to normal after several more iterations of the while loop. I am uncertain what is causing this. Thanks.
void Run()
{
startTime = millis();
lastLogTime = millis();
lcd.clear();
lcd.setCursor(0,0);
//Write Set Point to Screen
lcd.print("Sp: ");
lcd.print(Setpoint);
lcd.write(1);
lcd.print("C ");
SaveParameters();
myPID.SetTunings(Kp,Ki,Kd);
while(true)
{
buttonStateRight = digitalRead(buttonPinRight);
buttonStateLeft = digitalRead(buttonPinLeft);
if (buttonStateRight == buttonStateLeft && buttonStateRight == HIGH)
{
delay(200);
opState = MENU;
return;
}
if (tuning)
{
lcd.clear();
lcd.print(F("Tuning..."));
}
DoControl();
if (millis() - lastLogTime > logInterval)
{
//Write Input To Screen
lcd.setCursor(0,1);
lcd.print(Input);
lcd.write(1);
lcd.print("C : ");
//Write output percent to Screen
float pct = map(Output, 0, WindowSize, 0, 1000);
lcd.setCursor(10,1);
lcd.print(pct/10);
//lcd.print(Output);
lcd.print("% ");
//Log Data to Serial
lastLogTime = millis();
Serial.print((millis() - startTime)/10000);
Serial.print(" ");
Serial.print(Input);
Serial.print(" ");
Serial.print(Output/100);
Serial.print(" ");
Serial.println(Setpoint);
}
delay(100);
}
}