Comments: Graphic LCD Hookup Guide

Pages

Comments 9 comments

  • Russcky / last year * / 2

    I only got the code sample to work by restoring the commented code in the LCDWrite() function.

    //Send the data
      digitalWrite(scePin, LOW);
      SPI.transfer(data); //shiftOut(sdinPin, sclkPin, MSBFIRST, data);
      digitalWrite(scePin, HIGH);
    

    I simply dropped the SPI.transfter call and left the commented code of shiftOut.

    //Send the data
      digitalWrite(scePin, LOW);
      shiftOut(sdinPin, sclkPin, MSBFIRST, data);
      digitalWrite(scePin, HIGH);
    

    In addition, I used the following setting in the lcdBegin() function to get the best results of contrast and other capabilities:

    LCDWrite(LCD_COMMAND, 0x21); //Tell LCD extended commands follow
    LCDWrite(LCD_COMMAND, 0xc8); //Set LCD Vop (Contrast)
    LCDWrite(LCD_COMMAND, 0x12); //LCD bias mode 1:48 (try 0x13)
    LCDWrite(LCD_COMMAND, 0x20); //chip is active, horizontal addressing, use basic instruction set
    //We must send 0x20 before modifying the display control mode
    LCDWrite(LCD_COMMAND, 0x09); //temperature control
    LCDWrite(LCD_COMMAND, 0x0C); //Set display control, normal mode.
    
  • Hey all - I found Russky’s comment extremely helpful. Changing

    SPI.transfer(data); //shiftOut(sdinPin, sclkPin, MSBFIRST, data);
    

    to this:

    shiftOut(sdinPin, sclkPin, MSBFIRST, data);
    

    solved my problems.

    Also regarding the off-by-one character issue: there seems to be an error in the ASCII[] array. The array item for the character ‘]’ is listed twice:

      ,{0x00, 0x41, 0x41, 0x7f, 0x00} // 0x5d ]
      ,{0x00, 0x41, 0x41, 0x7f, 0x00} // 0x5d ]
    

    Deleting one of those lines solves the off-by-one problem.

    Cheers!

  • For those interested, I was able to scroll images across the screen by simply adding a simple new function of getPixel that allowed me to essentially loop over my image, getting the current value at a location, then placing that value slightly left or right on the display, over and over, scrolling the image left or right.

    // get a single pixel
    int getPixel(int8_t x, int8_t y, char *image) {
      if ((x < 0) || (x >= LCD_WIDTH) || (y < 0) || (y >= LCD_HEIGHT))
        return 0;
    
      return (image[x+ (y/8)*LCD_WIDTH] >> (y%8)) & 0x1;  
    }
    

    Hope this helps others!

  • Anyone know how to write a function that would scroll a bitmap (such at the sample xkcd cartoon) across the screen coming from completely off the screen on one side to off the screen on the other side?

    I’ve done something simple with using GotoXY, but that has problems with the wrapping of the image. I think I need to write parts of the xkcd bitmap to parts of the displayMap array but I’m finding that difficult to calculate how to do that.

  • I followed the writeup for the hookup and copied the code provided into a sketch. The code compiles and runs, but I don’t see anything on the display. I DO see the LED backlight brightness changing, so the coad has uploaded and runs…

    I’ve played around with a few things. I can modify the LED backlight, and can send data to the serial monitor with debug statements configured to show the bytes that LCDWrite is sending out the data line. So it’s TRYING to do something. I’ve experimented with the screen contrast and have tried changing the write method from SPI back to the commented out shiftOut statement.

    I’ve also downloaded the sketch: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/LCD/Monochrome/Nokia_5110_Example.pde which runs and displays to the LCD, but there is something weird going on with the ASCII table. Sometimes it works, but also I’m getting values that are off by one, and other values that are gibberish.

    Any suggestions?

    • For the code that doesn’t work, I’d really expect the problem to be contrast. Try using the same contrast as that of the sketch that works (I notice that one sets it to 55 and another to 40). Maybe even try every possible contrast value (0-127) with a for loop after you’ve drawn something.

      For the sketch that does work for you, which characters are printing gibberish or wrong values? Is it repeatable?

      • I’m having the same problem described above. I’ve tried contrast values from 0-127 with no luck. I also tried the sketch mentioned above and it works, with some ASCII table weirdness. The lower-case letters seem to be shifted. The display reads ‘Hfmmp Wpsme!’

  • When I click on the link to download LCD Assistant I get a message that I’m being blocked. Anyone else getting that or am I just special?

  • For me the PCD8544 is what I use instead of the typical 16x2 lcd screens. Not only can you do more with it, I think ease of use and connecting it up is about the same.


If you've found a bug or have other constructive feedback for our tutorial authors, please send us your feedback!