/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-lm35-temperature-sensor
*/
#define ADC_VREF_mV 5000.0 // in millivolt
#define ADC_RESOLUTION 1024.0
#define PIN_LM35 A0
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(4,OUTPUT );
}
void loop() {
// get the ADC value from the temperature sensor
int x = analogRead(A0);
// convert the voltage to the temperature in Celsius
float temp = (x*4.88) / 10;
if(temp>30)
digitalWrite(4, HIGH);
else
digitalWrite(4,LOW);
// print the temperature in the Serial Monitor:
Serial.print("Temperature: ");
Serial.print(temp); // print the temperature in Celsius
delay(2000);
}