20 * 4 LCD Display

Using a 20 * 4 LCD Display connected to a Mega Text displays to line 2, line 1, line 4 then line 3 instead of 1,2,3,4 (Using lcd.setCursor(0,0) to lcd.setCursor(0,3) Text characters are all correct order etc, just rows wrong,Tried 2 Displays

(Occassionally a reset will put the rows in the correct order)

Any help, suggestions please

Usually it will be

11111111111111111111 33333333333333333333 } these two are swapped 22222222222222222222 } 44444444444444444444

But your saying it is like this?

22222222222222222222 11111111111111111111 44444444444444444444 33333333333333333333

Its inside out.

Any help, suggestions please

It is not clear to me if you are setting the cursor and then displaying 80 characters or if you are setting the cursor after each 20 characters.

You should probably supply us with a short sketch that causes your problem. A photo of the display would help as well.

Don

Hi ,Thanks for responding

1st all it’s a OLED Display ,if that makes any difference.

Attached is the sketch.

As I’ve previously metioned, occasionally pressing reset will cause a 0,1,2,3 row readout. Thanks

#include <LiquidCrystal.h>

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

void setup()
{

lcd.begin(20,4);
lcd.clear();

}

void loop()
{

lcd.setCursor(2,0);
lcd.write(“The Geeze Rules 1”);
lcd.setCursor(1,1);
lcd.write(“The Geeze Rules 2”);
lcd.setCursor(2,2);
lcd.write(“The Geeze Rules 3”);
lcd.setCursor(1,3);
lcd.write(“The Geeze Rules 4”

A picture of the display would help us greatly.

1st all it's a OLED Display ,if that makes any difference.

In that case we need a link to the datasheet.

Don

Thanks for getting back to me

Data Sheet included in this
http://www.rapidonline.com/Electronic-Components/20x4-Oled-Display-Yellow-57-2302

1st Photo is display immediately after upload
2nd Photo is display after pressing Reset

Thanks for your assistance :

I think they are the same picture

OK - according to page 10 of the datasheet this device has the same (unusual) addressing scheme as most standard LCDs so that's not the problem.

I see that you are sending the information to the LCD over and over again very quickly, since there are no delays in your program. The LCD does not have to be refreshed so that if the information does not change it does not have to be resent. All of your code should be in setup() and loop() should be blank.

Try moving the code and see what happens.

Don

I think the rows and columns in the code are incorrect.

lcd.setCursor(2,0); // maybe you want this to be (0,0) lcd.write("The Geeze Rules 1"); lcd.setCursor(1,1); // maybe you want this to be (1,0) lcd.write("The Geeze Rules 2"); lcd.setCursor(2,2); // maybe you want this to be (2,0) lcd.write("The Geeze Rules 3"); lcd.setCursor(1,3); // maybe you want this to be (3,0) lcd.write("The Geeze Rules 4");

The one line is overflowing by one character that starts at column 3 and goes 17 characters

I think the rows and columns in the code are incorrect.

There's no way to tell what he intended since he did not comment his statements.

example:

  lcd.setCursor(2,0);                   // start text at column ... of row ...
  lcd.write("The Geeze Rules 1");
  lcd.setCursor(1,1);                   // start text at column ... of row ...
  lcd.write("The Geeze Rules 2");
  lcd.setCursor(2,2);                   // start text at column ... of row ...
  lcd.write("The Geeze Rules 3");
  lcd.setCursor(1,3);                   // start text at column ... of row ...
  lcd.write("The Geeze Rules 4");

The one line is overflowing by one character that starts at column 3 and goes 17 characters

He doesn't have anything starting at column 3.

Syntax
lcd.setCursor(col, row)

Don

Yes, you are correct! I read the syntax wrong - doh...

Thanks for your response
Slightly adjusted Code

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//LiquidCrystal lcd(38, 40, 42, 44, 46, 48);

void setup()
{

lcd.begin(20,4);
lcd.clear();

}

void loop()
{

lcd.setCursor(0,0);
lcd.write(“The Geeze Rules 1”);
lcd.setCursor(0,1);
lcd.write(“The Geeze Rules 2”);
lcd.setCursor(0,2);
lcd.write(“The Geeze Rules 3”);
lcd.setCursor(0,3);
lcd.write(“The Geeze Rules 4”

This Code works fine on a 20 * 4 LCD Display (Not the OLED Display) Contrast not so good. Even after pressing reset a number of times and in the order laid out in the sketch

(Image attached)

Loading the same sketch on the OLED is as these images (Rows all incorrect)

After pressing reset for a third time text becomes as garbage

Any thoughts please

Thanks

I have no clue on the OLED - sorry.

On the LCD, do you have an adjustable resistor for the contrast? Also called a trimpot / potentiometer...

Pressing the reset button should start your sketch over on the Arduino. The serial back pack I'm using has a reset circuit that resets the display at the same time my arduino resets.

Maybe one of the experts here knows if a display reset is required every time the arduino is reset. You could accomplish the same thing by unplugging the power supply - assuming the display and arduino are using the same power. You probably know all this already...

Slightly adjusted Code

Try 'adjusting' it a little more and see what happens:

From reply #8: "I see that you are sending the information to the LCD over and over again very quickly, since there are no delays in your program. The LCD does not have to be refreshed so that if the information does not change it does not have to be resent. All of your code should be in setup() and loop() should be blank."

Don

On the LCD, do you have an adjustable resistor for the contrast? Also called a trimpot / potentiometer...

His contrast is fine, you can see that from the photos.

Pressing the reset button should start your sketch over on the Arduino. The serial back pack I'm using has a reset circuit that resets the display at the same time my arduino resets.

This was a problem with some ancient versions of the LiquidCrystal library. All of the recent versions (several years worth) take care of resetting the LCD controller with software when the Arduino restarts the library.

Maybe one of the experts here knows if a display reset is required every time the arduino is reset. You could accomplish the same thing by unplugging the power supply - assuming the display and arduino are using the same power. You probably know all this already...

The display should be reset since you do not know where it was (in it's internal program) when it stopped getting instructions from the Arduino. Unplugging the power supply would accomplish this as you stated.

Don

Thanks for your all your input.Now Solved!

First Linked together the Reset pin of the Arduino to the Reset Pin of the OLED Display

This synchronised the Arduino with the Display.Display showed Lines 0 to 3 in correct order even after Multiple Resets

But... Would now not program!!!

Used a 1k and a 680nf(critical) filter in series between the Reset pins and now works fine

Thanks again for all your support

thegeeze: Thanks for your all your input.Now Solved!

But you really haven't responded to our input, or to mine at least, and I don't think that all of your problems are really solved. You still haven't fixed the improper structure of your program so you are probably going to run into other problems as you try to do more with the display.

Don