Program the Crystal display board to show temperature values from temp sensor

As the title says for my project I built the love-o-meter but I want to know if its possible to program the crystal display board that comes with the arduino starter kit with the temp sensor. So when making the love o meter as soon as you touch it, the detected temperature shows up on the display. Can someone tell me if this is possible and how with the code and circuit build?

Also I tried this program and an error shows up can someone tell me how to fix this?

*Also attached is the error message we receive when we try to upload the program to the Arduino circuit.

/*
Arduino Starter Kit example
Project 11 - Crystal Ball

This sketch is written to accompany Project 11 in the
Arduino Starter Kit

Parts required:
220 ohm resistor
10 kilohm resistor
10 kilohm potentiometer
16x2 LCD screen
tilt switch

Created 13 September 2012
by Scott Fitzgerald

http://www.arduino.cc/starterKit

This example code is part of the public domain
*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// set up a constant for the tilt switchPin
const int switchPin = 6;

// variable to hold the value of the switchPin
int switchState = 0;

// variable to hold previous value of the switchpin
int prevSwitchState = 0;

// a variable to choose which reply from the crystal ball
int reply;

void setup() {
// set up the number of columns and rows on the LCD
lcd.begin(16, 2);

// set up the switch pin as an input
pinMode(switchPin, INPUT);

// Print a message to the LCD.
lcd.print(“Ask the”);
// set the cursor to column 0, line 1
// line 1 is the second row, since counting begins with 0
lcd.setCursor(0, 1);
// print to the second line
lcd.print(“Crystal Ball!”);
}

void loop() {
// check the status of the switch
switchState = digitalRead(switchPin);

// compare the switchState to its previous state
if (switchState != prevSwitchState) {
// if the state has changed from HIGH to LOW
// you know that the ball has been tilted from
// one direction to the other
if (switchState == LOW) {
// randomly chose a reply
reply = random(8);
// clean up the screen before printing a new reply
lcd.clear();
// set the cursor to column 0, line 0
lcd.setCursor(0, 0);
// print some text
lcd.print(“the ball says:”);
// move the cursor to the second line
lcd.setCursor(0, 1);

// choose a saying to print baed on the value in reply
switch (reply) {
case 0:
lcd.print(“Yes”);
break;

case 1:
lcd.print(“Most likely”);
break;

case 2:
lcd.print(“Certainly”);
break;

case 3:
lcd.print(“Outlook good”);
break;

case 4:
lcd.print(“Unsure”);
break;

case 5:
lcd.print(“Ask again”);
break;

case 6:
lcd.print(“Doubtful”);
break;

case 7:
lcd.print(“No”);
break;
}
}
}
// save the current switch state as the last state
prevSwitchState = switchState;

/*
Arduino Starter Kit example
Project 3 - Love-O-Meter

This sketch is written to accompany Project 3 in the
Arduino Starter Kit

Parts required:
1 TMP36 temperature sensor
3 red LEDs
3 220 ohm resistors

Created 13 September 2012
by Scott Fitzgerald

http://www.arduino.cc/starterKit

This example code is part of the public domain
*/

// named constant for the pin the sensor is connected to
const int sensorPin = A0;
// room temperature in Celcius
const float baselineTemp = 23.0;

#define SENSOR 0 // select the input pin for
// the LM335A temperature sensor

// open a serial connection to display values
Serial.begin(9600);
// set the LED pins as outputs
// the for() loop saves some extra coding
for (int pinNumber = 2; pinNumber < 5; pinNumber++) {
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, LOW);

// read the value on AnalogIn pin 0
// and store it in a variable
int sensorVal = analogRead(sensorPin);

// send the 10-bit sensor value out the serial port
Serial.print("sensor Value: ");
Serial.print(sensorVal);

// convert the ADC reading to voltage
float voltage = (sensorVal / 1024.0) * 5.0;

// Send the voltage level out the Serial port
Serial.print(", Volts: ");
Serial.print(voltage);

// convert the voltage to temperature in degrees C
// the sensor changes 10 mV per degree
// the datasheet says there’s a 500 mV offset
// ((volatge - 500mV) times 100)
Serial.print(", degrees C: ");
float temperature = (voltage - .5) * 100;
Serial.println(temperature);

// if the current temperature is lower than the baseline
// turn off all LEDs
if (temperature < baselineTemp + 2) {
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
} // if the temperature rises 2-4 degrees, turn an LED on
else if (temperature >= baselineTemp + 2 && temperature < baselineTemp + 4) {
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
} // if the temperature rises 4-6 degrees, turn a second LED on
else if (temperature >= baselineTemp + 4 && temperature < baselineTemp + 6) {
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
} // if the temperature rises more than 6 degrees, turn all LEDs on
else if (temperature >= baselineTemp + 6) {
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
}
}

The error is telling you that you need one more "}" at the very end of your program to close your "void loop {" function. Once you add that it compiles.

@josh_d thanks it worked! but do u have any clue how to program the temperature sensor to show its values on the display board?

Nummyz:
@josh_d thanks it worked! but do u have any clue how to program the temperature sensor to show its values on the display board?

Its pretty much all there in your code already.

Take the value you have for temperature in the second example, and then use the "lcd.print();" command you use in your first example to display it.

Can you put you code in tags as well please, it makes things easier to read.

Nummyz:
@josh_d thanks it worked! but do u have any clue how to program the temperature sensor to show its values on the display board?

Try this,

#include <LiquidCrystal.h>

#define sensorPin 0 // select the input pin for the LM335A temperature sensor

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);



void setup() {


  // put your setup code here, to run once:
  // set up the number of columns and rows on the LCD
  lcd.begin(16, 2);


}

void loop() {
  // put your main code here, to run repeatedly:

  int sensorVal = analogRead(sensorPin);

  float voltage = (sensorVal / 1024.0) * 5.0;   // convert the ADC reading to voltage

  float temperature = (voltage - .5) * 100;     //convert the voltage to temperature in degrees C, the sensor changes 10 mV per degree, the datasheet says there's a 500 mV offset ((volatge - 500mV) times 100)

  lcd.clear();                                  // clean up the screen before printing a new reply

  lcd.setCursor(0, 0);                          // set the cursor to column 0, line 0

  lcd.print("Temperature");                     // print some text

  lcd.setCursor(0, 1);                          // move the cursor to the second line

  lcd.print(temperature);                       //print the temperature value

  delay(100);                                   //delay for stability
}

I did that in 5 min using the code you had already supplied. I didnt test it as i dont have that sensor, but it compiles fine.

@aussietom Ok thanks! I rebuilt the circuit and used the code you gave with a minor conversion of Celsius to Fahrenheit. Sorry for the long reply wait. Also I'm sure this is probably because of an error with the circuit but if i place both fingers on the temp sensor the values do change correspondingly but there's a 7 that shows up consistently making the temp seem like its value to be in the 700's and the values fluctuate too much. When its not touched and left alone it shows the avg room temp (73.84 in F) . I'll try rebuilding the circuit to se eif it was an error in that. I;m sure the code is perfectly fine though.