LCD 20x4 createChar compilation error [Solved]

Hi guys.

I’m trying to use createChar() with 20x4 LCD and compile with errors. The LCD work, the code work… the problem is only with createChar. This is the output:

Any idea?

Try 0b instead of B to use the binary option. (At least think this is supported as I don’t tend to use this myself as it is not portable)

[EDIT] Yes, I just checked so use 0b (that’s a zero) and it should work.Capital or lower B works but lower is considered the standard in the same way as 0X and 0x when used for HEX.

1 Like

https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html

as @v8dave says, 0b notation works, but not in all compilers, we use gcc so we’re good to go!

byte smiley[8] = {
  0b00000,
  0b10001,
  0b00000,
  0b00000,
  0b10001,
  0b01110,
  0b00000,
};

or you could write it in hexadecimal with 0x… or just decimal

byte smiley[8] = { 0,17,0,0,17,14,0 };

byte smiley[8] = {
  0x00,
  0x11,
  0x00,
  0x00,
  0x11,
  0x0E,
  0x00,
};
2 Likes

Thank you guys.

0b works but the createChar() don’t show the char… I´m trying and i reply if this work.

1 Like

Guys, another problem.
The chars are a block. Any ideia?


This is maybe a silly suggestion, I haven't played with this library at all -- but the documentation for createChar seems to imply it should be cast as a byte and not a char, does that work?

Thanks,
David

Hi Dave. I found the solution (uint8_t):

LiquidCrystal lcd(D1, D2, D3, D4, D5, D6);
uint8_t charWif[8] = {0x0,0x0,0x1,0x3,0x7,0xf,0x1f,0x0};
uint8_t charBat[8] = {0x0,0x6,0xf,0x9,0xf,0xf,0xf,0x0};

void setup() {
    lcd.begin(20,4);
    lcd.createChar(1, charWif);
    lcd.createChar(2, charBat);
}

void loop() {
    lcd.setCursor(18, 0);
    lcd.write(1);
    lcd.write(2);
}

Now it works. Thank you.

1 Like