void setup() {
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
pinMode(2, OUTPUT);
}
void loop() {
// Get the voltage reading from the LM35
int reading = analogRead(34);
// Convert that reading into voltage
float voltage = reading * (5.0 / 4095.0);
// Convert the voltage into the temperature in Celsius
float temperatureC = voltage * 100;
// Print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println("°C");
if(temperatureC>30){
digitalWrite(2, HIGH);
}
else
digitalWrite(2, LOW);
delay(1000); // wait a second between readings
}
//https://lastminuteengineers.com/lm35-temperature-sensor-arduino-tutorial/