const int sensorPin = A0;
float voltage, temperatureC;
void setup() {
Serial.begin(9600);
// Step 4: Use internal 1.1V reference (optional)
// analogReference(INTERNAL); // Uncomment to test internal reference
}
void loop() {
int adcValue = analogRead(sensorPin);
// Convert ADC value to voltage (assuming 5V reference)
voltage = adcValue * (5.0 / 1023.0);
// LM35 outputs 10mV per °C
temperatureC = voltage * 100;
Serial.print("ADC Value: ");
Serial.print(adcValue);
Serial.print(" | Voltage: ");
Serial.print(voltage, 3);
Serial.print(" V | Temperature: ");
Serial.print(temperatureC, 1);
Serial.println(" °C");
delay(1000);
}