Variables:
int TuWas = LOW;
float tmin = 25.0;
float tmax = 28.0;
loop() calls:
Code: Select all
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
}
else {
Serial.print(tempC);
Serial.print(" C");
}
if (tempC < tmin) {
TuWas = HIGH;
}
if (tempC > tmax) {
TuWas = LOW;
}
...
}
I see in output the temperature values. Initially the first comparison is true, so TuWas is set to High. But later on the temp increases above tmax, but TuWas never gets set to Low. Why?
Any help greatly appreciated!
EDIT:
Solved. In the ellipsis (...) part i had:
If (TuWas = HIGH);
which seems to not only compare, but also assign
Replace with
If (TuWas)
all works.
While at it: If i need the equality compare, how can i avoid this side effect?