// Define the pin where the LM35 is connected
#define TEMP_SENSOR_PIN A0 // LM35 connected to analog pin A0
void setup() {
// Initialize serial communication
Serial.begin(9600); // Start the serial communication at 9600 baud rate
}
void loop() {
// Read the analog value from the LM35 sensor
int analogValue = analogRead(TEMP_SENSOR_PIN);
// Convert the analog value to voltage
float voltage = analogValue * (5.0 / 1024.0);
// Calculate the temperature in Celsius
float temperatureC = voltage * 100.0; // LM35 gives 10 mV per °C, so multiply by 100
// Print the temperature to the Serial Monitor
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
// Wait for a second before taking another reading
delay(1000); // Delay of 1000 milliseconds (1 second)
}