Arduino Forum

Products => The Arduino Starter Kit and Basic Kit => Topic started by: norton421 on Dec 08, 2014, 02:58 pm

Title: Project 3 - Love-O-Meter
Post by: norton421 on Dec 08, 2014, 02:58 pm

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...