Arduino LCD Display Custom Characters Problem

Hello,

I have a problem with my 20*4 LCD display and my custom characters. I want to have a big I on my LCD display, to do that I tried this with customChar. Only now there is a problem, as can be seen in the picture, the first character is now the wrong way round,
but what can't be because it's different in the code, how can you fix it so that the characters are all displayed correctly?

void Test()
{

  byte CustChar1[] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B00000,
    B00000,
    B00000,
    B00000
  };
  
  byte CustChar2[] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111
  };
  
  byte CustChar3[] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B00000,
    B00000,
    B00000,
    B00000
  };
  
  byte CustChar4[] = {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  };

  byte CustChar5[] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111
  };

  byte CustChar6[] = {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  };
  
  byte CustChar7[] = {
    B00000,
    B00000,
    B00000,
    B00000,
    B11111,
    B11111,
    B11111,
    B11111
  };
  
  byte CustChar8[] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111
  };
  
  byte CustChar9[] = {
    B00000,
    B00000,
    B00000,
    B00000,
    B11111,
    B11111,
    B11111,
    B11111
  };
  
  lcd.createChar(0, CustChar1);
  lcd.createChar(1, CustChar2);
  lcd.createChar(2, CustChar3);
  lcd.createChar(3, CustChar4);
  lcd.createChar(4, CustChar5);
  lcd.createChar(5, CustChar6);
  lcd.createChar(6, CustChar7);
  lcd.createChar(7, CustChar8);
  lcd.createChar(8, CustChar9); 
  
  for (int i = 0; i < 3; ++i)
  {
    lcd.setCursor(i + 0, 0);
    lcd.write(i);
    lcd.setCursor(i + 0, 1);
    lcd.write(i + 3);
    lcd.setCursor(i + 0, 2);
    lcd.write(i + 3);
    lcd.setCursor(i + 0, 3);
    lcd.write(i + 6);
    delay(150);
  }
}

Please draw and post an illustration of what you want.

The display only supports 8 custom characters.

1 Like

good catch.
positions 8 to 15 are the same characters/memory as 0 to 7
so using custom character position 8 overwrites data at custom character position 0.

--- bill

There are only 4 characters shown or defined.

Characters 4 and 6 are the same as the space character.

Characters 2, 8 and 5 are the same as 0xFF in the LCD's Asian character set.

Characters 1 and 3 are the same, characters 7 and 9 are the same.

As already others said, you can't define more than 8 custom characters, and you have 9.
Anyway, you just need 3 (or 4 if you include the space) of them to draw an uppercase "I". Something like this (untested):

void Test()
{
  // Space
  byte CustChar0[] = {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  };
  // Upper square
  byte CustChar1[] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B00000,
    B00000,
    B00000,
    B00000
  };
  // Full
  byte CustChar2[] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111
  };
  // Lower square
  byte CustChar3[] = {
    B00000,
    B00000,
    B00000,
    B00000,
    B11111,
    B11111,
    B11111,
    B11111
  };
  
  lcd.createChar(0, CustChar0);
  lcd.createChar(1, CustChar1);
  lcd.createChar(2, CustChar2);
  lcd.createChar(3, CustChar3);
  
  // "I" definition (char codes, 3 chars by 4 rows)
  byte chrcode[4][3] = { { 1,2,1 }, { 0,2,0 }, { 0,2,0 }, { 3,2,3 } };
  
  for (int i=0; i < 4; ++i) {
    lcd.setCursor(i, 0);
    for(int j=0; j<3; ++j)
      lcd.write(chrcode[i][j]);
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.