Help me connect my LCD to my mega !

Hi everybody,

First hello everyone, I'm new in the Arduino World.

I have my Mega for... two days and doing all the exercises etc. I can find on this site. I also bought a LCD screen that I'm trying to connect to my board. Problem is that the PIN mapping doesn't seem to be the same than on regular Arduino, and I'm a bit at a loss.

Potentiometer and contrast DO work though (I'm proud for a newbie !)

Maybe this has been described many times, but I didn't find by doing searches in the forum, except about the graphical screen which is obviously another beast.

When I try to compile the basic programs I can find, I get the error "error:no matching function for call to 'LiquidCrystal:LiquidCrystal()". It has been installed and is available under sketches, so I guess the problem lies somewhere else. Any pointers welcome, and sorry for being such a noob.

(sorry for the multiple post but otherwise I could not put links)

My screen is http://www2.produktinfo.conrad.com/datenblaetter/175000-199999/181664-da-01-en-LCD_MODUL_STN_POSITIV_LED_WEISS_16X2.pdf

I tried to tweak it as said here but I think I'm a bit too newbie to understand really what I need to do... http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210427907/99#99

As you noticed, the thread you linked is for a completely different kind of LCD display. Yours uses the LiquidCrystal library and (unlike the Grapical LCD) there is nothing mega specific about the code.

What Arduino version are you using and what is your operating system?

If you made any change to the example sketch or LiquidCrystal library, best to put it back the way it was.

Yes I noticed it was not for the same screen, but I also noticed that in the thread it was said that the pins were not the same on the Mega. So I'm confused now, because if I put the cables as said here for instance : http://arduino.cc/it/Tutorial/LCDLibrary it does not work (of course I map them to the proper pin on my LCD as per the LCD documentation) and I get the error message mentioned above when compiling.

I didn't change anything on the library, just asking :wink:

I am using arduino-0016 (the latest release available for download on the official site) with the built-in libraries.

My Arduino is the Mega (are there many releases ?) and I run on the interface on Windows Vista.

Thanks for your help !

The difference between the two libraries is that the LiquidCrystal library uses digitalWrite to set the pins and the graphical library writes directly to the hardware. The graphical library bypasses digitalWrite because it has can make thousands of writes to fill a screen and each write takes up to 30 times longer with digitalWrite. But (unlike the graphical library) digitalWrite will work without change on any of the supported Arduino boards including the mega.

In short – you don't need to change the LiquidCrystal library to use it with the Mega. But you do need to get the wiring to match the code in your sketch.

Is your lcd wired up to match the pins in the example sketch?

Also, if you compile the example sketch and LiquidCrystal library (as distributed), do you get an error?

If you don't get an error and its wired correctly but still does not work, read floresta's post in this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1246364438/3#3

Thanks, Ill check all this.

For the wiring, I'll check, except that on my screens the pins go from 14-->1 then 16, 15 if I read properly the pdf linked above.

But basically, I get a compile error (error:no matching function for call to 'LiquidCrystal:LiquidCrystal()) even with the most basic example. I can understand it could not run if the wiring is not ok, but at least it should compile ok on my computer no ?

Edit : this code (given on the lcd tutorial) does not compile

#include <LiquidCrystal.h> //include LiquidCrystal library

LiquidCrystal lcd = LiquidCrystal(); //create a LiquidCrystal object to control an LCD

void setup(void){
  lcd.init(); //initialize the LCD
  digitalWrite(13,HIGH); //turn on an LED for debugging
}

void loop(void){
  delay(1000); //repeat forever
}

This one does

#include <LiquidCrystal.h>

// LiquidCrystal display with:
// rs on pin 12
// rw on pin 11
// enable on pin 10
// d4, d5, d6, d7 on pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

void setup()
{
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop()
{
}

Is the code on the tutorial obsolete ?

... given on the lcd tutorial)
Which tutorial? Do you mean this: http://arduino.cc/it/Tutorial/LCDLibrary ?

If so, it is obsolete. It refers to another library with the same name, not the current distributed Arduino library. Perhaps if someone knows how to contact Heather Dewey-Hagborg (the author of that tutorial) it can be updated to reflect the current library (or deleted)

So, stick with the example code that compiles, wire it up as shown in the diagram I posted above and see if it works.

Ok thanks yes I was using that tutorial as a starting point.

Let's try again then. Seems my port mapping is slightly different than the one you gave me, though, but I use it as a sample. Will let you know how that works !

Edit : now backlight + monitor + potentiometer do work, code is ok too (the sample hello world code), but it still doesn't work.

So either I mixed something in the wiring, either I'll check for the other post you mentioned previously.

Seems we are many to share the same issue...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241881879

Still not working...

I cannot use your wiring diagram because the pins do not correspond to my LCD pin layout... so what I have so far :

Why do you think that? How do the pins in pin assignment diagram you posted differ from the ones in the diagram I posted?

The table you posted is not correct for the pin assignments in the distributed sketch (and the diagram I posted), try this:

Arduino PIN LCD screen PIN Description
10 6 Enable
11 5 RW
12 4 RS

5 11 DB4
4 12 DB5
3 13 DB6
2 14 DB7

edit: did you change your post - your diagrams are longer there

Yes sorry because I realized I did some mistakes in my diagrams, still based on the old tutorial.

I'll try what you just posted (I think that what I have now, but I'll double check)

here are my screen diagram again

Edit: yes I have the same pin assignement now. Still doesn't work :'(. Always those squares on first line and nothing on second line


If it's wired correctly and still doesn't work then follow the link I posted in reply #4. Some LCDs do not initialize correctly with the official LiquidCrystal library. There is a newer version under development that will fix this but it may be some time before it is released. In the mean time you can try the version of the library in that link.

Thanks but I did already, didn't change anything...

Think I'm going to buy another screen :frowning:

To make sure that your sketch is using the correct library you must delete the LiquidCrystal.o file after copying in the revised LiquidCrystal.cpp file (http://web.alfredstate.edu/weimandn/arduino/LiquidCrystal_library/LiquidCrystal.cpp)

Yes this is what I did. I rechecked and rewired everything too but no success.

Tried also the 4lib but same result...

Here are some pics of my circuit and my screen... (in case I REALLY missed something crucial that I don't see, otherwise it will add some color in that thread !)

And thanks for your time, Mem :slight_smile:

You are connecting to the analog in pins. You should be connected to the pins on the other side of the board (they are marked PWM, but really should be marked PWM/DIGITAL)

Wow I owe you one here. THANKS SO MUCH ! (sorry for screaming but after trying for hours, it's a victory !)

Obviously it works much better when connected to the correct pins. sometimes some pics are worth a thousand words...

glad to hear you have it going.

have fun!

I got it working on my Mega using the setup as illustrated at
(I can't seem to post a web address?!?!). Basically:

LCD pin name RS EN DB4 DB5 DB6 DB7
Arduino pin # 7 8 9 10 11 12

But I wanted to save these "PWM" pins for other use. So I moved the pins and updated the sketch as follows:

LCD pin name RS EN DB4 DB5 DB6 DB7
Arduino pin # 22 23 24 25 26 27

Thus :
LiquidCrystal lcd(22, 23, 24, 25, 26, 27);

However I get nothing when I do this? Is that because the LiquidCrystal driver does know about these new pins?

Thanks,
B2

PS: be kind I'm a Arduino Noob ;D

LiquidCrystal can certainly use those pins. I would double check the wiring.