Hi everybody,
could someone explain me why the following scketch doesn't work? Is a stupid program with 3 leds and a 4.7 kohm thermistor (that one included in the workshop kit - base level).
The problem is that always lights the red led even if the temperature rises from 22°C (green led) to 23 °C (yellow led).
Serial monitor gives me the correct temperature but the red led is always on!!!
Maybe the if cycle is wrong...
Attached the frizing sketch!
Thanks

#include <math.h>
const int sensorPin = 1;
int sensorValue;
int led1 = 2; //green led
int led2 = 4; //yellow led
int led3 = 7; //red led
float tensione;
float Rt;
float temp;
void setup() {
pinMode (led1,OUTPUT);
pinMode (led2,OUTPUT);
pinMode (led3,OUTPUT);
Serial.begin(9600);}
void loop() {
sensorValue = analogRead(sensorPin);
tensione=4.83-((4.83*sensorValue)/1024);
Rt=20000*((4.83-tensione)/tensione);
temp = 10.5915*tensione*tensione - 55.5533*tensione + 67.3157;
Serial.print(sensorValue);
Serial.print(" -> ");
Serial.print(tensione);
Serial.print(" -> ");
Serial.print(Rt);
Serial.print(" (");
Serial.print(temp);
Serial.println(" gradi)");
if(temp <= 23);
{digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);}
if(temp > 23 && temp <= 38);
{digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);}
if(temp > 38);
{digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);}
delay(500);
}
moderatore added code tags -> use the # button above the smileys,