10 years, 10 months ago.

help on 2x16 LCD

really need your help to make this 2x16 LCD work

text wont appear on my LCD

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7
           //rs   e    d4  d5   d6    d7
int main() {
    lcd.printf("Hello World!\n");
}

/media/uploads/menski/dsc_0035_-medium-.jpg /media/uploads/menski/dsc_0033.jpg

this is my LCD datasheet MODEL: SC162A3 http://www.digitron.com.cn/Attachs/Pdf/201181870862673.pdf

Hi Kilo byte, Thanks for asking the question. I had the same question on how to interface an LCD to LPC 1768. Wim, Erik and Gorazad replied to your question and that helps me too. However, I would like to add a couple of more observations. It is better to solder pins to LCD terminals and plug in the LCD to a breadboard or a connector. Connecting wires can be used to connect from the breadboard or connector to the LPC 1768. This ensures reliable connections. Several issues related to the projects can be solved by ensuring good connections.

posted by Moorthy Muthukrishnan 06 Aug 2014

3 Answers

10 years, 10 months ago.

Hi kilo byte,

Erik is right, you will need to connect LCD pin3 to the appropriate contrast voltage to see anything on the display. The top row of the display will usually show up as black rectangles as soon as power and contrast voltage are applied. It also seems that you have not connected pin 5 to GND. That is the Read/Write pin and it should always be at logic low level for the mbed LCD library to work. I also recommend that you dont use non-isolated alligator clips for the connection between mbed and the LCD. The likelyhood of a shortcircuit is pretty high and you could easily damage mbed output ports. Obviously a short will also mean that the software does not work.

Accepted Answer

Hi Wim, your assistance has been a great help to me and its much appreciated. I manage to display characters on my LCD. but the letters doesnt seem to complete the screen. (view pic http://i40.tinypic.com/2iwapfl.jpg). do you have any ideas why?

im still using d4-d7 pins. so im guessing, the missing blocks are from d0-d3?

posted by kilo byte 29 Jul 2013

You dont need d0-d3 when using the 4 bit mode. The displayed result in your picture could be caused by a bad portpin or bad connection on d4-d7. Could also be a software problem. Please post your code.

posted by Wim Huiskamp 29 Jul 2013

where can i read/learn more about other modes? as you said, im using 4 bit mode, i want to know why im using 4 bit mode. also, you can see the code below im using that i found on a forum somewhere

#include "mbed.h"
#include "TextLCD.h"

DigitalIn test(p21);

TextLCD lcd(p10, p12, p15, p16, p19, p20); // rs, e, d4-d7
           //rs   e    d4  d5   d6    d7
int main() {
while(1) {
    if (test == 1) {
    lcd.locate(1,1);
    lcd.cls();
    lcd.printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678\n");  }
}
}
posted by kilo byte 29 Jul 2013

The LCD has an 8 bit databus (d0-d7). You would need 8 mbed pins to program it that way. The LCD also supports a special 4-bit mode in order to save some of these valuable processor pins. In 4 bit mode the actual 8 bit data is send to the display is two parts of 4bit each. You can find out more about that by reading the datasheet of the HD44780 controller.

Your example software is continuously updating the display at a very high rate when the test pin is high. Perhaps you should slow that down a bit or do just one printf to test the display. The fact that you see only part of the message may be caused by a problem with timing or by a bad/shorted connection between d4-d7 and mbed.

#include "mbed.h"
#include "TextLCD.h"

DigitalIn test(p21);

TextLCD lcd(p10, p12, p15, p16, p19, p20); // rs, e, d4-d7
           //rs   e    d4  d5   d6    d7
int main() {
    lcd.locate(1,1);

    lcd.printf("ABCDEFGH");
    lcd.printf("IJKLMNOP");
    lcd.printf("QRSTUVWX");
    lcd.printf("YZ123456");

    while(1) {};
}

posted by Wim Huiskamp 29 Jul 2013

Thank you Wim! its now working :) i needed to re-solder some pins and imported your program. i really appreciate your help and Erik.

posted by kilo byte 30 Jul 2013
10 years, 10 months ago.

Wim has alot more knowledge regarding these displays than I have, but you haven't connected the VEE pin, which is according to the cookbook page the normal location of the contrast pin. If that is floating it probably isn't doing what you want it to do, you should connect it to a potmeter to set the contrast.

Afaik if due to whatever problem the display isn't initialized, it should show the top row all character spots black. So I think it simply is a contrast problem.

10 years, 10 months ago.

Allso this kind of clamp wiring is a little bit risky. How do you know, that the contacts are good, and that the upper nibble data pins are not in short circuit? I would solder the wires directly to the LCD, or solder a pin heared if you want to keep the LCD for further development. And yes, without Vee (contrast) you will not manage to see anything on LCD. For a quick test, you can apply a 200ohm resistor between pin 3 and pin 1 (gnd), and you should see at least something.

Regards