Go Down

Topic: Project 3 - Love-O-Meter (Read 899 times) previous topic - next topic



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 :

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

Or anything similar...

Go Up