16x2 LCD two lines of text at once

Hi everyone,

I will really appreciated it if some one could help me.
I have these 3 problems, I've been trying to display 2 lines of text in my LCD,
But it doesn't show anything, then it shows the: 3, 2, 1 lines of text, but not the Welcome Project. :confused:

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Welcome");
  lcd.print("Project");
  delay(4000);
}

void loop(){
  lcd.setCursor(0, 0);
  lcd.print("3");
  delay(1000);
  lcd.print(ant);
  }
  lcd.setCursor(0, 0);
  lcd.print("2");
  delay(1000);
  lcd.setCursor(0, 0);
  lcd.print("1");
  }

What I wanted to do is to show the "Welcome Project" only once, and then keep looping the 3, 2, 1.
But for some reasons it doesn't show the "Welcome Project" only the: 3, 2, 1.
Any help and suggestion will be appreciated it.
Thanks in advance.

That code doesn't even compile.

Hi Pert,

What do you mean the code doesn't even copile?
when I run this code it doesn't show nothing for like 6 seconds, then it shows the: 3, 2, 1. but it does not show the "Welcome Project".

I mean just that.

  • Copy the above code to your Arduino IDE
  • Sketch > Verify/Compile
  • Compilation fails with the following errors:
C:\Users\accou\AppData\Local\Temp\arduino_modified_sketch_506877\sketch_jan15a.ino: In function 'void loop()':

sketch_jan15a:16: error: 'ant' was not declared in this scope

   lcd.print(ant);

             ^

C:\Users\accou\AppData\Local\Temp\arduino_modified_sketch_506877\sketch_jan15a.ino: At global scope:

sketch_jan15a:18: error: 'lcd' does not name a type

   lcd.setCursor(0, 0);

   ^

sketch_jan15a:19: error: 'lcd' does not name a type

   lcd.print("2");

   ^

sketch_jan15a:20: error: expected constructor, destructor, or type conversion before '(' token

   delay(1000);

        ^

sketch_jan15a:21: error: 'lcd' does not name a type

   lcd.setCursor(0, 0);

   ^

sketch_jan15a:22: error: 'lcd' does not name a type

   lcd.print("1");

   ^

sketch_jan15a:23: error: expected declaration before '}' token

   }

   ^

Please always test code before posting it to the forum.

I deleted that part and used only this:

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Welcome");
  lcd.print("Project");
  delay(4000);
}

void loop(){
  lcd.setCursor(0, 0);
  lcd.print("3");
  delay(1000);
  }

And does it work as expected?

Is working, but can't figured out how to set "Welcome Project" as multiline like so:
Welcome
Project

This is where lcd.setCursor() is needed:

The arguments set the column and row. Note they are zero-indexed. Since you want to print "Project" on the second row, starting from the first column you need to add this line before you print "Project":

lcd.setCursor(0, 1);

I tried, but doing it this way:

void setup() {
  lcd.begin(16, 2);
  lcd.setCursor(0, 1);
  lcd.print("Welcome");
  lcd.print("Project");
  delay(4000);
}

I only get printed "Project" in the second row!

You didn't read my instructions in the last reply carefully.

Take a minute to understand what your code is actually doing:

  lcd.setCursor(0, 1);  // set the cursor to first column, second row
  lcd.print("Welcome");  // print "Welcome" at first column, second row
  lcd.print("Project");  // print "Project" at first column, second row

So actually it does print "Welcome" but it's only for a tiny fraction of a second before it's overwritten by "Project". You want to print "Welcome" at the first column, first row. So what should the arguments be in the setCursor statement before you print "Welcome"?

I see what you meant Pert,
I got it, this worked for me:

  void setup() {
    lcd.begin(16, 2);
    lcd.setCursor(0, 0);
    lcd.print("Welcome");
    lcd.setCursor(0, 1);
    lcd.print("Project");
    delay(4000);
  }

@pert,

I would expect to see WelcomeProject on the second line.
After all, it is a 16x2 display. So it should be able to fit 15 letters.

If you get anything different, I would suspect you have installed some hacked library.

@Coder,

If you want separate lines, setCursor before you print.
It looks as if you have fixed it now.

David.

Thank you for your suggestion David,
And yes, I fixed, now is printing 1 & 2 rows at once.
Thank you guys

C0der

david_prentice:
If you get anything different, I would suspect you have installed some hacked library.

I don't even have an LCD on hand so I merely assumed that was what was going on. I only ever used an LCD on one project years ago and I was using a different library. My projects that require a display have all been network connected so I just use my computer monitor as the display.

pert:
I don't even have an LCD on hand so I merely assumed that was what was going on. I only ever used an LCD on one project years ago and I was using a different library. My projects that require a display have all been network connected so I just use my computer monitor as the display.

The type of output device does not usually matter when it comes to multiple print() outputs.
Even if you were using a serial monitor, if you do two back to back to back Serial.print() statements they will still be on the same line.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
lcd.begin(16, 2);
lcd.clear();
}

void loop()
{
lcd.clear();

lcd.print("Top text");
lcd.setCursor(0, 2);
lcd.print("Bottom Text");

delay(3000);

}

That's interesting.

Don

floresta:
That's interesting.

But apparently posted with no regard for the forum requirements.

And also - by the way - simply wrong! :astonished:

That's what makes it interesting.

Don

Did not even read the preceding discussion, it seems.