20x4 LCD problem

i have a problem with displaying a long text (larger than 20 character),the problem is the text is displayed on two row not one(the first line and the third).
i want this long text to be displayed on one line and scrolling.
the code is

#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 7, 6, 5, 4);
void setup()
{
lcd.begin(20, 4);
lcd.clear();
}
void loop()
{
lcd.autoscroll();

lcd.setCursor(0, 0);
lcd.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789");

delay(1000);
}

Never done that, but I know HD44780 defenitivelly supports that command. Have you tried with any 3rd party library?

Try this (untested):
(1) Move the autoscroll command into setup, there's no need to execute it each time around the loop.
(2) Set your cursor to the end of the line, not the beginning.

Don

casemod:
Never done that, but I know HD44780 defenitivelly supports that command. Have you tried with any 3rd party library?

No i don't tried.
any suggestion ?

floresta:
Try this (untested):
(1) Move the autoscroll command into setup, there's no need to execute it each time around the loop.
(2) Set your cursor to the end of the line, not the beginning.

Don

i tested it.
Stil not working.

I cannot remember where I saw it or if it's fixed now but I recall reading that the LiquidCrystal library does not work properly with 20x4 displays.

i tested it.
Stil not working.

What does it display?

Don

I cannot remember where I saw it or if it's fixed now but I recall reading that the LiquidCrystal library does not work properly with 20x4 displays.

That's news to me.

The cursor positioning does not work properly when used with the 16x4 displays.

Don

floresta:

i tested it.
Stil not working.

What does it display?

Don

it display the text in two lines (1 and 3) and scrolling it.

Riva:
I cannot remember where I saw it or if it's fixed now but I recall reading that the LiquidCrystal library does not work properly with 20x4 displays.

that is a bad news

abdelmohsen:

Riva:
I cannot remember where I saw it or if it's fixed now but I recall reading that the LiquidCrystal library does not work properly with 20x4 displays.

that is a bad news

No problem, it's not true and has never been true. Did you read reply #7.

Don

it display the text in two lines (1 and 3) and scrolling it.

That's really not very descriptive.
Where does the first character appear?
What happens when the second character is sent?
What happens after the 20th character is sent?

It is probably working properly, it's just not what you expect or want.

You need to know how the addressing works in order to understand what is happening. Try following the LCD Addressing link at http://web.alfredstate.edu/weimandn. Make sure you read the information about the 40x2 before looking at the 20x4 information.

Don

floresta:

it display the text in two lines (1 and 3) and scrolling it.

That's really not very descriptive.
Where does the first character appear?
What happens when the second character is sent?
What happens after the 20th character is sent?

It is probably working properly, it's just not what you expect or want.

You need to know how the addressing works in order to understand what is happening. Try following the LCD Addressing link at http://web.alfredstate.edu/weimandn. Make sure you read the information about the 40x2 before looking at the 20x4 information.

Don

Thank you very much
now i can understand how it's addressed
it will need a much work to work as I want

Thank you again

Why not post some pictures?

Rather than just helping yourself it would be interesting if the issue could be documented and be available on the forum for other members with similar issues.

It would also be easier to spot some problems

that is what was displayed

that is what was displayed

A (huge) static picture does not help in a case like this. In order to determine if there is a problem we need the answers to the questions in reply #11.

We also need to see the code that is being used after incorporating the suggestions in reply #2..

Don

I am seeing the exact same issue, and was going to create my own post when I saw this.
I have a sainsmart 2004 20x4 I2c lcd. I am using the FM liquid crystal library, and am seeing the same behavior.
I think it is related to the LCD addressing link, but I would have thought the lcd library would handle that.
Here is my code:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x3F  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
  lcd.begin (20,4);
  lcd.home (); // go home
  lcd.print("This is 26 characters long");
}

void loop() {
}

And the output looks like:

This is 26 character

s long

Is there some initialization trick, or do I have to write a bunch of string processing code myself to deal with strings > 20?

simnick:
I am seeing the exact same issue, and was going to create my own post when I saw this.
I have a sainsmart 2004 20x4 I2c lcd. I am using the FM liquid crystal library, and am seeing the same behavior.
I think it is related to the LCD addressing link, but I would have thought the lcd library would handle that.
Here is my code:

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x3F  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
  lcd.begin (20,4);
  lcd.home (); // go home
  lcd.print("This is 26 characters long");
}

void loop() {
}




And the output looks like:


This is 26 character

s long



Is there some initialization trick, or do I have to write a bunch of string processing code myself to deal with strings > 20?

The sketch you gave simply prints 26 characters on the LCD. You need to tell it to scroll, otherwise anything above what the LCD supports will either not be shown or placed on the next line.

To scroll you have to do something like this:

lcd.scrollDisplayLeft();
lcd.setCursor(0,0);
lcd.print("abcd");

This could also be usefull
http://arduino.cc/en/Tutorial/LiquidCrystalScroll

If you want it to scroll both left and right you need to use a loop

will either not be shown or placed on the next line.

But that is the issue. I expect it to be placed on the next line, not two lines down.

But that is the issue. I expect it to be placed on the next line, not two lines down.

Your expectations are too high considering that the controller was designed about thirty years ago.

Have you looked at the link in reply #11?

Don