/**
Basic NTC Thermistor demo
https://wokwi.com/arduino/projects/299330254810382858
Assumes a 10K@25℃ NTC thermistor connected in series with a 10K resistor.
Copyright (C) 2021, Uri Shaked
*/
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
int potval,i1;
int analogValue,temp1;
float celsius;
void setup() {
Serial.begin(9600);
pinMode(4,OUTPUT);
}
void loop() {
analogValue = analogRead(A0);
potval = analogRead (1);
potval = map(potval,0,1023,0,100);
celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
Serial.println(potval);
delay(1000);
temp1 = celsius;
//Serial.println(temp1);
if (potval>celsius)
{
digitalWrite(4, HIGH);
}
else
{
digitalWrite(4, LOW);
}
if (potval - temp1 >10)
{
i1 = 255;
}else
if (potval -temp1 >5)
{
i1 = 175;
}else
if(potval -temp1 >3)
{
i1 = 75;
}else
{
i1 =0;
}
Serial.println(i1);
/*for (i1=0;i1<255;i1++)
{
analogWrite(3,i1);
delay (100);
Serial.println(i1);
}*/
}