int LED[4] = {2,3,4,5};
int sensorPin = A0;
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for(int i=0; i< 4; i++){
pinMode(LED[i], OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
int val = analogRead(sensorPin);
float celsius = 1 / (log(1 / (1023. / val - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.println(celsius);
for(int i = 0; i < 4; i++){
digitalWrite(LED[i], LOW);
}
if(celsius > 40 && celsius < 45){
digitalWrite(LED[0], HIGH);
}
else if(celsius > 45 && celsius < 59){
digitalWrite(LED[0], HIGH);
digitalWrite(LED[1], HIGH);
}
else if(celsius > 49 && celsius <53){
digitalWrite(LED[0], HIGH);
digitalWrite(LED[1], HIGH);
digitalWrite(LED[2], HIGH);
}
else if(celsius > 53 ){
digitalWrite(LED[0], HIGH);
digitalWrite(LED[1], HIGH);
digitalWrite(LED[2], HIGH);
digitalWrite(LED[3], HIGH);
}
delay(100);
}