Project 3 - Love-O-Meter

Gentlemen,

It seems there is a bug in the Love-O-Meter, in the way the temperature checks are done.

Assume the base line temperature is 20 °C.

First “if” tests for temperature<20 → ok
Second “if” tests for temperature>22 → ok, but what happens if temperature is, say 21?

In fact, if temperature is 21°C, the previous value will be retained, which is not the supposed behaviour.

Code should be changed to :

if(temperature<baselineTemp){
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
} else if(temperature >= baselineTemp && temperature < baselineTemp+2){
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4,LOW);
}else if (temperature >= baselineTemp+2 && temperature < baselineTemp+4){
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
}else if (temperature >= baselineTemp+4){
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
}

Or anything similar…