#define led_g 2
#define led_y 3
#define led_r 4
#define temp A1
void setup() {
pinMode(led_g, OUTPUT);
pinMode(led_y, OUTPUT);
pinMode(led_r, OUTPUT);
pinMode(temp, INPUT);
Serial.begin(115200);
}
void loop() {
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
int analogValue = analogRead(temp);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
{if (celsius >= 10 && celsius <= 15){
digitalWrite(led_g, HIGH);
}
else (celsius < 10 && celsius > 15);
digitalWrite(led_g, LOW);
}
{if (celsius > 15 && celsius <= 20){
digitalWrite(led_y, HIGH);
}
else (celsius < 15 && celsius > 20);
digitalWrite(led_y, LOW);
}
{if (celsius > 20){
digitalWrite(led_r, HIGH);
}
else (celsius < 20);
digitalWrite(led_r, LOW);}
Serial.print("AnalogValue ");
Serial.println(analogValue);
//delay(1000);
Serial.print("Temperarura ");
Serial.println(celsius);
}