I have a question about some code and weird anomalies.
Basic LCD functions:
float inside_temp;
float outside_temp;
float target = 74.00;
//inside_temp and outside_temp are values from 2 ds18b20's
inside_temp = 70.70;
outside_temp = 70.81;
LCD works when using this code with it commented out like this. Compiled size 5,928 bytes.
if(inside_temp < target){
//create a limit so heater isn't crazy hot as 5 gallons takes a while to change temp
// float limit = target + 1;
// if(outside_temp > limit){
// digitalWrite(RELAY_PIN, LOW);
// lcd.print("OFF");
// }
// else{
digitalWrite(RELAY_PIN, HIGH);
lcd.print("ON");
// }
}
else{
digitalWrite(RELAY_PIN, LOW);
lcd.print("OFF");
}
LCD also works with this code. Compiled size 5,590 bytes.
// if(inside_temp < target){
//create a limit so heater isn't crazy hot as 5 gallons takes a while to change temp
float limit = target + 1;
if(outside_temp > limit){
digitalWrite(RELAY_PIN, LOW);
lcd.print("OFF");
}
else{
digitalWrite(RELAY_PIN, HIGH);
lcd.print("ON");
}
// }
// else{
// digitalWrite(RELAY_PIN, LOW);
// lcd.print("OFF");
// }
LCD does NOT work when uncommented. Compiled size 5,992 bytes. All it does is sit there with the backlit on and no text.
http://imgur.com/xPAzY0N,DdGdYoIif(inside_temp < target){
//create a limit so heater isn't crazy hot as 5 gallons takes a while to change temp
float limit = target + 1;
if(outside_temp > limit){
digitalWrite(RELAY_PIN, LOW);
lcd.print("OFF");
}
else{
digitalWrite(RELAY_PIN, HIGH);
lcd.print("ON");
}
}
else{
digitalWrite(RELAY_PIN, LOW);
lcd.print("OFF");
}
I don't understand why this happens. Can I not structure code like this?