This project was my first as is about as simple as they get, but I thought I would share anyway. The code is made up of bits I stitched together, borrowed from other projects.
#include <LiquidCrystal.h> //import LCD library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //define connections for lcd
const int sense = A0; //define analog input
void setup(){
Serial.begin(9600); //open a serial port
lcd.begin(16, 2); //define lcd size
lcd.setCursor(2,0);
lcd.print("Temperature:");
lcd.setCursor(6,1);
lcd.print("C");
lcd.setCursor(12,1);
lcd.print("F");
}
void loop(){
int senseVal = analogRead(sense); //read sensor value
float volt = (senseVal/1024.0)*5.0; //convert ADC reading to voltage
Serial.print("Temperature: ");
int tempC = (volt - .5)*100; //convert the voltage to temperature in degrees
int tempF = (tempC*9/5+32); //convert centigrade to farenheit
Serial.print(tempC);
Serial.print(" C, ");
Serial.print(tempF);
Serial.println(" F");
lcd.setCursor(3,1);
lcd.print(" "); //clears display for next reading
lcd.setCursor(3,1);
lcd.print(tempC);
lcd.setCursor(9,1);
lcd.print(" ");
lcd.setCursor(9,1);
lcd.print(tempF);
delay(1000); //wait 1 second between readings
}