// Reference https://docs.wokwi.com/parts/wokwi-ntc-temperature-sensor
#define sensorPin A0
#define BETA 3950
int ledArray[] = {4,5,6,7,8,9,10,11,12,13};
float level = (80 + 24)/10.0;
void setup() {
// initialize LEDs and sensor pin
pinMode(sensorPin, INPUT);
for (int i=0; i<10; i++){
pinMode(ledArray[i], OUTPUT);
}
}
void loop() {
// Read the sensor value , calculate the temperature, light up the leds
float celsius = 1 / (log(1 / (1023. / analogRead(sensorPin) - 1)) / BETA + 1.0 / 298.15) - 273.15;
for (int i=0; i<10; i++){
if (celsius > -24 + (level*(i+1))){
digitalWrite(ledArray[i], HIGH);
}
else {
digitalWrite(ledArray[i], LOW);
}
}
delay(10); // this speeds up the simulation
}