/* Arduino Sketch for reading temperature from the Analog sensor LM-35 The sensor temperature can be viewed in the Serial Monitor of Arduino IDE in PC */ // Global declarations float sensorTemp = 0.0; // For storing raw data from LM-35 float Temperature = 0.0; // For storing the converted temperature int analogInputPin = 0; // Data out of LM-35 is connected in Arduino's analog Pin A0 void setup(){ Serial.begin(9600); } void loop(){ sensorTemp = analogRead(analogInputPin); // Reads sensor data from pin A0 Temperature = sensorTemp * 0.48875855; //(+Vcc * 1000 / 1023) / 10 // Line 18-21 prints a formatted output Serial.print("Temperature = "); Serial.print(Temperature); Serial.print(char(176)); //Unicode character degree sign (U+00B0) is 176 in Decimal Serial.print("C\n"); delay(5000); // Temperature is printed in the Serial Monitor every five seconds }