void setup()
{
pinMode(3,OUTPUT);
pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop()
{
int read =analogRead(A0);
int vout = (read/1024.0)*5000;
int celsius=vout/10-49;
Serial.print("Reading is ");
Serial.println(celsius);
if(celsius>30)
{
digitalWrite(3,1);
}
else
{
digitalWrite(3,0);
}
}
Explain : We can use temperature sensor TMP36 in this because LM35 is not available. We attach a bulb so when temperature increase by 30 degree celsius bulb on. For LM35 use : int read =analogRead(A0); int vout = read*4.88; int celsius=vout/10;