LCD special characters

I got an LCD hooked up to my particle photon (via the digital pins - not using I2C)

Had really good success with writing normal characters to the screen. Got the idea of saving writing space by using special characters. but it doesn’t work…

Tried this:

https://www.arduino.cc/en/Reference/LiquidCrystalCreateChar

#include <LiquidCrystal.h>

LiquidCrystal lcd(5, 4, 3, 2, 1, 0);

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() {}

but it gave me an error with the byte(0) call and with the B#####

Then I tried this:

This worked without errors, but gave a strange character…

https://omerk.github.io/lcdchargen/

#include <LiquidCrystal.h>

// initialize the library
LiquidCrystal lcd(5, 4, 3, 2, 1, 0);
            
byte customChar[8] = {
	0b01110,
	0b10101,
	0b11111,
	0b01010,
	0b01110,
	0b00100,
	0b11111,
	0b11111
};
void setup()
{
  // create a new custom character
  lcd.createChar(0, customChar);
  
  // set up number of columns and rows
  lcd.begin(16, 2);
   // print the custom char to the lcd
  // why typecast? see: http://arduino.cc/forum/index.php?topic=74666.0
  lcd.write((uint8_t)0);
}

void loop()
{
  
}

Wanted this character

but got this

You do intend to use the pins A2, A1, D5, D4, D3, D2?

We do appreciate when the pins are addressed with their full “names” :wink:

You may want to add some other bitmaps to get a better understanding of what’s actually going wrong here.
With a sample of one character in a nominal-actual comparison it’s not easy to guess the cause.

And for superstition (or “cleaner” style IMO) you could try moving lcd.begin() before actually using the lcd (i.e. before lcd.createChar()).

In addition to @ScruffR suggestions, once you have written your special chars to the display memory you need set the display memory back to its normal mode as createChar() doesn’t. You do this by calling lcd.setCursor(), lcd.clear() or lcd.home() before writing to it.

If you don’t do this you just end up with corrupted gibberish where the custom chars are displayed.

1 Like

Sorry… I just copy pasted the code… In my setup it’s

LiquidCrystal lcd(5, 4, 3, 2, 1, 0);

I updated the question…

Moving the creation of the character after lcd.begin() did the trick! Thank you so much!!

1 Like