Arduino Forum

Using Arduino => Displays => Topic started by: carlosdiazme on Dec 18, 2016, 02:30 am

Title: 16x1 LCD showing only first 8 characters (lcd.setCursor(0,1) not working)
Post by: carlosdiazme on Dec 18, 2016, 02:30 am
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:

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):
(http://i.imgur.com/jBaH8LU.jpg)

Came here, and saw the DDRAM addressing, and looking the datasheet of my display found Att2:
(http://i.imgur.com/yGs5cLN.png)

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):
(http://i.imgur.com/2r0TM39.jpg)

So, now I don't know what I'm doing wrong.
Thanks in advance for any help.
Title: Re: 16x1 LCD display showing only first 8 characters (lcd.begin(8, 2); not working)
Post by: floresta on Dec 18, 2016, 05:23 am
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 (http://web.alfredstate.edu/weimandn) for an explanation of what's behind all this.

Don
Title: Re: 16x1 LCD display showing only first 8 characters (lcd.begin(8, 2); not working)
Post by: carlosdiazme on Dec 18, 2016, 02:48 pm
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:
(http://i.imgur.com/HOiF21F.jpg)

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 (http://web.alfredstate.edu/weimandn/lcd/lcd_addressing/lcd_addressing_index.html) link at http://web.alfredstate.edu/weimandn (http://web.alfredstate.edu/weimandn) you gave me was very useful.
Regards,
Carlos.
Title: Re: 16x1 LCD display showing only first 8 characters (lcd.begin(8, 2); not working)
Post by: david_prentice on Dec 18, 2016, 05:43 pm
You call it 8x2
positions 0-7 are 0-7 on line#1
positions 8-15 are 0-7 on line#2

David.
Title: Re: 16x1 LCD display showing only first 8 characters (lcd.begin(8, 2); not working)
Post by: carlosdiazme on Dec 18, 2016, 06:12 pm
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
Title: Re: 16x1 LCD showing only first 8 characters (lcd.setCursor(0,1) not working)
Post by: floresta on Dec 18, 2016, 11:11 pm
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