Go Down

Topic: Values does not update itself on the LCD but does on the serial comm (Read 992 times) previous topic - next topic


Hi guys, I have a problem with my 16 pin LCD currently. I'm making a thermostat which displays the current temperature and selected temperature(temperature is chosen using a potentiometer).
On the LCD it should display values for "Set to:" and "Currently:". Now here is the weird part, the "Currently" values seems to update itself however the "Set to" does not respond to changes made to the potentiometer. Funny thing is that it both values update itself on the serial comm and is working perfectly. Any ideas what is happening? Also, there are unnecessary lines being displayed as well. How do i get rid of those? I've added a picture!

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal.h>

int tmp102Address = 0x48;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int potPin = A0; //analog 0
int relayPin = 1;// digital 2

int lowTemp = 25; //lowest temp in C you can set it to
int highTemp = 35; //highest temp in C you can set it to

void setup(){
  pinMode (relayPin,OUTPUT);

void loop(){

  float temperatureSetAt = getThreshold();
  float currentCelsius = getTemperature();
  if(temperatureSetAt < currentCelsius){
   digitalWrite(relayPin, HIGH); //turn it on
    digitalWrite(relayPin, LOW); //turn it off
  lcd.print("Set to:");
  lcd.setCursor(0, 2);
  Serial.print("Set Celsius:");
  Serial.print("Current Celsius: ");

  delay(2000); //just here to slow down the output. You can remove this

float getThreshold(){
int potVaule = analogRead(potPin);
potVaule = map(potVaule, 0, 1023, lowTemp, highTemp);

float floatValue = (float)potVaule;
return floatValue;

float getTemperature(){

  byte MSB = Wire.read();
  byte LSB = Wire.read();

  //it's a 12bit int, using two's compliment for negative
  int TemperatureSum = ((MSB << 8) | LSB) >> 4;

  float celsius = TemperatureSum*0.0625;
  return celsius;


A couple of things I can see...
Code: [Select]
lcd.print("Set to:");
  lcd.setCursor(0, 2);

Your not doing a setCursor before the initial lcd.print of Set to: so it may not be printing where you expect it to. The other is your using .println instead of .print to send temperatureSetAt & currentCelsius so your getting a couple of strange characters on the lcd.
Don't PM me for help as I will ignore it.


You should also do (0, 1) instead of (0, 2). The rows are zero-based, row 0 is the first row, row 1 is the second row.

lcd.setCursor(0, 1);
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Go Up