A very Basic Way of Interfacing a LM35 Temperature Sensor to an Arduino.

The Basic Test Code to show the Values in Serial Monitor is Given Here:

Arduino Code:
  1.  
  2. float tempC;
  3. int tempPin = 0;
  4.  
  5. void setup()
  6. {
  7. Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
  8. }
  9.  
  10. void loop()
  11. {
  12. tempC = analogRead(tempPin); //read the value from the sensor
  13. tempC = (5.0 * tempC * 100.0) / 1024.0; //convert the analog data to temperature
  14. Serial.print((byte)tempC); //send the data to the computer
  15. delay(1000); //wait one second before sending new data
  16. }
  17.  

Another Way Of Reading The Temperature,, but in this case the Resulution has Been Improved:

Arduino Code:
  1.  
  2. float tempC;
  3. int reading;
  4. int tempPin = 0;
  5.  
  6. void setup()
  7. {
  8. analogReference(INTERNAL);
  9. Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
  10. }
  11.  
  12. void loop()
  13. {
  14. reading = analogRead(tempPin);
  15. tempC = reading / 9.31;
  16. Serial.print((byte)tempC);//send the data to the computer
  17. Serial.print(" C");
  18. Serial.println();
  19. delay(1000); //wait one second before sending new data
  20. }
  21.  
  22.