Go Down

Topic: Formatting the output, JHD204A LCD (Read 1 time) previous topic - next topic

schumo

Hello, i'm new here and i have a question.
I connected the JHD204a LCD display to Arduino Duemilanove. I get positioning the cursor, and printing simple things. Now i started another project and i need help. Is there any way to print something like this
Code: [Select]
The values are: X;Y;Z;//X,Y,Z are variables

I started like this:
Code: [Select]
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int x = 0;
int y = 0;
int z = 0;

void setup() {
  lcd.begin(20, 4);
  lcd.print("Hello World");
}

void loop() {
  lcd.setCursor(0, 1);
  x=millis()/1000;
  lcd.print(x);
  lcd.setCursor(2, 1);
  lcd.print(";");
  y=x*2;
  lcd.setCursor(3, 1);
  lcd.print(y);
  z=y*2;
  lcd.setCursor(5, 1);
  lcd.print(";");
  lcd.setCursor(6, 1);
  lcd.print(z);
}

This prints pretty much what i need, until some of the variables reach 3-digits, then print overlaps. Is there any way to automatically move the ";" markers to make room for more digits. Thx in advance :)

NickPyner

I have wondered the same thing.  Like having a variable in the command -  lcd.setCursor(p, 1); and converting data into strings of a fixed length.
I have found that using leading zeros, like

  lcd.print(minute);
  lcd.print(":");
     if ((second) < 10)
  {
    lcd.print("0");
  };
   lcd.print(second);

and junk-clearing blanks like

  lcd.print("     ");

suffice so far.....

dhenry

What I do in those cases is to form a string / buffer and send that buffer to the lcd in one shot.

schumo

Thanks for quick reply. I will try this.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy