#define temp A0
#define fan 2
#define threshold 25
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
float celsius;
int readValue;
void setup()
{
Serial.begin(9600);
pinMode(fan, OUTPUT);
} // end of setup()
void loop()
{
readValue = analogRead(temp);
celsius = (40./(1023.))*readValue;
Serial.print("Read value = ");
Serial.println(readValue);
Serial.print("Actual value = ");
Serial.println(celsius);
if(celsius>threshold)
{
digitalWrite(fan, HIGH);
}
else
{
digitalWrite(fan, LOW);
}
delay(500);
} // end program