Go Down

Topic: 16x1 LCD showing only first 8 characters (lcd.setCursor(0,1) not working) (Read 5356 times) previous topic - next topic

carlosdiazme

I know this is a very common and discussed topic around here: 16x1 LCD displays showing only the left half of the 16 characters. But, for me, the usual solution (lcd.begin(8, 2); and lcd.setCursor(0, 1);) doesn't work at all.

Some data of my LCD display:
  • Manufacturer: Xiamen Ocular
  • Model: GDM1601A  (datasheet)
  • Characters: 16x1
  • LCD Controller/Driver: ST7066U (datasheet)

First, I tried:
Code: [Select]

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  lcd.begin(16, 1);
  lcd.print("Hello, world!");
}
void loop() {
}

Result: only the first 8 characters are visible (Att1):


Came here, and saw the DDRAM addressing, and looking the datasheet of my display found Att2:


So I tried codes using "two lines":
Code: [Select]

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  lcd.begin(8, 2); // IMPORTANT: I also tried lcd.begin(16, 2);, with the same unwanted result.
  lcd.print("Hello, w");
  lcd.setCursor(0, 1);
  lcd.print("orld!");
}
void loop() {
}

Result: no characters at all were visible (Att3):


So, now I don't know what I'm doing wrong.
Thanks in advance for any help.

floresta

You code looks correct to me.

Try sending a string of 80 characters and see what happens when the cursor positioning is taken out of the equation.

Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
  {
    lcd.begin(8, 2);                           // put your LCD parameters here
    for (char i=47; i<127; i++)                // send 80 consecutive displayable characters to the LCD
      {
        lcd.print(i);
        delay(100);                            // this delay allows you to observe the addressing sequence
      }
  }


void loop()
  { 
  }


Make sure you let it run long enough, there will be a delay after the first 8 characters are displayed before the other 8 show up.

Check out the LCD Addressing link at http://web.alfredstate.edu/weimandn for an explanation of what's behind all this.

Don

carlosdiazme

Thank you very much for your quick reply Don.

It's solved.

I executed the code you gave me, and I noticed the display showing the characters on byte positions 00h through 07h for the left half of the display, and byte positions 40h through 47h for the right half of the display:


So, the generic solution for my display will be:
Code: [Select]

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
    lcd.begin(16,2);     // or lcd.begin(8,2);
    lcd.print("First8ch");
    lcd.setCursor(40,0); // Works for showing characters on the right half of GDM1601A controlled 16x1 LCD displays.
    lcd.print("Last8ch.");
  }
void loop()
  {
  }


Again, thank you very much.
The LCD Addressing link at http://web.alfredstate.edu/weimandn you gave me was very useful.
Regards,
Carlos.

david_prentice

You call it 8x2
positions 0-7 are 0-7 on line#1
positions 8-15 are 0-7 on line#2

David.

carlosdiazme

You call it 8x2
positions 0-7 are 0-7 on line#1
positions 8-15 are 0-7 on line#2
I thought that too, but I found that setting the cursor to line#2 (lcd.setCursor(0,1) followed by lcd.print("SomeText")) doesn't show SomeText on the right half of the display. Only setting the cursor to column 41 (40, counting from 0) of line#1 did the trick.

Carlos

floresta

You call it 8x2
positions 0-7 are 0-7 on line#1
positions 8-15 are 0-7 on line#2

David.
Isn't that what he was doing in his second program of the original post (between the two pictures)?  I think it should have worked and the DDRAM address info in that first post supports this.  

Maybe they have tinkered with the library behind our backs.  As far as I can tell they have never addressed (pardon the pun) the fact that there are two distinctly different breeds of 16x1 displays.

Don

Go Up