Weird problem with specific pixels in LCD createChar

Hi,
I've been trying to debug my code to print custom characters in 16X2 LCD, and after a day of work trying to compare to the smiley example (which works) with my code, I pinpointed the problem to one pixel.

I started changing bit by bit of the first row, from 0 to 1, compiling every time, until the smiley stopped printing.
The culprit is bit[1] of the top row in smiley definition. Make it 0, it all compiles and and a smiley is printed. Make it 1 and it compiles but nothing is printed.
Below is the full code. I don't have another LCD module to test. Can anyone reproduce the problem?

Thanks.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // RS, E, D4, D5, D6, D7

 byte smiley[8] = {
  B11101,
  B10001,
  B00000,
  B00000,
  B10001,
  B01110,
  B00000
};

void setup() { 
 
  lcd.createChar(0, smiley);
  lcd.setCursor(3, 2);
  lcd.write(byte(0));

Change the smiley assignment to :

byte smiley[8] = {

  • B11111,*
  • B10001,*
  • B00000,*
  • B00000,*
  • B10001,*
  • B01110,*
  • B00000*
    };

and it stops printing.

What happens if you use 0b00011101 and 0b00011111 instead of the #defined values ?

Please post a complete sketch that demonstrates the problem.

Why do you put only 7 bytes in your 8-byte array?

I took the examples as is from this Arduino site.
I didn't post the whole code because it's dirty with failed attempts commented out, but what I posted is the whole working code, except for the final closing bracket that I missed pasting.

Do you mean the CreateChar example?

#include <LiquidCrystal.h>

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

byte smiley[8] = {
 B00000,
 B10001,
 B00000,
 B00000,
 B10001,
 B01110,
 B00000,
};

void setup() {
 lcd.createChar(0, smiley);
 lcd.begin(16, 2); 
 lcd.write(byte(0));
}

void loop() {}

Note how the example has " lcd.begin(16, 2);" where you have " lcd.setCursor(3, 2);", which, by the way, is trying to display on the third line?!? Undo that change and you will find that it works much better.

Hi John,
thanks for your reply.
I eliminated the lcd.begin because it blanks the screen. I found it empirically but later found an explanation in the forum.
Set cursor (3,2) I think it's Position 3, line 2. Even if I'm wrong, I've tried all kind of positions.
After all the tests, I downed it to 1 bit (pixel), that if I set it, it doesn't print anything, and if clear it, the char is printed. Tried it many times and the behavior is consistent.
Anyway, I'm leaving this project because I think the 16X2 LCD is not the right HW to display different alphabets, and it's futile to "convince it" with SW tricks.
Thanks again for your help.
David.

Set cursor (3,2) I think it's Position 3, line 2

Correct, but you don't have a line 2 only lines 0 and 1