Oct 272013
 

Character LCDs are displays that consist of many character “blocks”, and each block can display a letter, number, etc.
In the world today, there is one display controller/driver that dominates this market, the Hitachi HD44780 driver. I have talked about this in another post on reverse engineering a printer LCD.
HD44780-based character LCDs usually come in common sizes such as 16×2 (16 characters per line, two lines), 8×2, 20×2 20×4, using the 8-bit ASCII character set.
Interestingly enough, the HD44780 chip allows up to 8 custom characters to be defined. These can contain any bitmap data, and can be updated as often as you like.
With this in mind, we can construct basic bitmap images for the display, with a resolution of 20×16 pixels if we have four custom characters per line, occupying two lines, 15×16 if we have three per line on two lines (two are still available but not used) or a 40×8 display if we put all eight on one line.
However, there is a gap between each character so images will have gaps, and symmetry can get messed up if you don’t design it correctly.

I connected a standard 16×2 character LCD to my Arduino via a Proto Shield (excuse the messy wiring) and hacked together some code for the custom characters.
I have created a very low-resolution version of the Hack a Day logo for their Trinket competition. The goal is to put their logo in interesting places. Nobody has done this before, so I figured it would be fun to try out.

Here’s the original image for a comparison
Hack a Day logo

My final logo ended up using six of the custom characters for a 15×16 pixel resolution (3×2 resolution in characters) as there are things in the centre which are split in the character gaps so four characters per line can’t work. I finally had to do it this way after too much trial and error using all 8 characters for a 20×16 resolution.

Click on the images for a higher resolution version.

I think the result turned out nicely, considering what the actual display was designed for.
Here’s a link to the Arduino sketch I wrote up with the bitmap:
lcd_hackaday.ino

 Posted by at 12:16 AM

  2 Responses to “Bitmap images on character LCDs”

  1. If you have a 4 line LCD try running this. (this is for a black on white display, you’d have to invert the custom characters to make it look good on a white on black)

    // include the library code:
    #include

    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(7,6,5,4,3,2);

    // make some custom characters:
    byte hackaday.0.0 [8] = {
    0b11111,
    0b11111,
    0b11011,
    0b11001,
    0b00001,
    0b10001,
    0b11111,
    0b11110,
    };
    byte hackaday.0.1 [8] = {
    0b00000,
    0b00000,
    0b00000,
    0b00000,
    0b00000,
    0b00000,
    0b11111,
    0b11111,
    };
    byte hackaday.0.2 [8] = {
    0b11111,
    0b11111,
    0b11011,
    0b10011,
    0b10000,
    0b10001,
    0b11111,
    0b01111,
    };
    byte hackaday.1.0 [8] = {
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b00000,
    };
    byte hackaday.1.1 [8] = {
    0b00000,
    0b11011,
    0b10001,
    0b00000,
    0b00100,
    0b00100,
    0b00000,
    0b01010,
    };
    byte hackaday.1.2 [8] = {
    0b01111,
    0b01111,
    0b01111,
    0b01111,
    0b01111,
    0b01111,
    0b01111,
    0b00000,
    };
    byte hackaday.2.0 [8] = {
    0b11111,
    0b10001,
    0b00001,
    0b11001,
    0b11011,
    0b11111,
    0b11111,
    0b11111,
    };
    byte hackaday.2.2 [8] = {
    0b11111,
    0b10001,
    0b10000,
    0b10011,
    0b11011,
    0b11111,
    0b11111,
    0b11111,
    };

    void setup() {

    // set up the lcd’s number of columns and rows:
    lcd.begin(20, 4);

    // load the custom characters into the LCD
    lcd.createChar(0, hackaday.0.0);
    lcd.createChar(1, hackaday.0.1);
    lcd.createChar(2, hackaday.0.2);
    lcd.createChar(3, hackaday.1.0);
    lcd.createChar(4, hackaday.1.1);
    lcd.createChar(5, hackaday.1.2);
    lcd.createChar(6, hackaday.2.0);
    lcd.createChar(7, hackaday.2.2)
    lcd.clear();
    // print them out
    lcd.setCursor(6, 0);
    for(int i=0; i<3; i++) lcd.print((char)i);
    lcd.setCursor(6, 1);
    for(int i=3; i<6; i++) lcd.print((char)i);
    lcd.print((char)6);
    lcd.write(255);
    lcd.print((char)7);

    }

    void loop() {
    //nothing to do here…
    }

  2. […] [Joseph's] entry is drawn on a character LCD. He posted info on how he went from vector graphic to custom characters. […]

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>