LCD library pin constraints on Mega?

I have an LCD working on Duem./328 using 0017 and the standard example in the code, hello world.

Same LCD moved over to a Mega, moved the pin interface over to the “double socket” pins in the 41 to 53 range, I’m using all odd numbered pins on that socket.

The LCD is not getting past the “top half dark” initialization problem.

Just wondering if the LCD library supports the higher-numbered pins of the Mega? I’ve used the higher numbers in the LCD initialization string and get no complaints.

One thing I am doing differently on the Mega is using an I/O output HIGH to power the LCD. Powering the LCD is the first thing I do… then a pause a couple seconds. Before I start using LCD commands.

Tell me this: when does the initialization of LCD happen?

In the pre-amble before setup() I have this:

#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(51,49,47,45,43,41);

Does the initialization happen BEFORE setup runs?

If so, I do not have the LCD powered yet.

You should probably power the LCD from the +5V and not on of the digital I/O's. Not sure how much power the LCD pulls but the I/O pin is more limited then the +5V pin.

I should power the LCD from +5, but not because of power draw. (It only draws a couple mA, so that's fine for an I/O pin.)

I just read the Library tutorial, and it says the included library classes run BEFORE setup(). This mean LCD initialization is happening before the LCD is powered. So I can't power the LCD from an I/O pin in setup(), no matter what flavour of Arduino hardware I'm using. It's not a Mega issue.

I guess if I really wanted, I could edit the LCD library or create my own library class that powers on the LCD by flipping an I/O pin HIGH, and place this code before the LCD initialization string. Maybe put a bit of a delay after powering it up to allow it the LCD to stabilize. It would be good practice at making a library at least, and keep power control of the LCD in the code.

(It only draws a couple mA, so that's fine for an I/O pin.)

OK good to know.

Creating a new class in the existing library is a good idea. You could add a define power pin class.

Not over yet. I wired the LCD to +5 all the time. Still no joy! Doesn't seem to be initializing (top row dark, bottom row not).

I tested the LCD again on a Duem./328 and it's good, using the LCD 'hello world' code sample.

Flashed the Mega/1280 with same code sample (of course changed pin numbers to match the LCD connector pinout on that shield), and no joy. LCD has power, but doesn't seem to be initializing. Using same Arduino 0017 install for all experiments here.

I triple checked wiring.. to make sure I haven't crossed something up.. shorted anything, and got the mapping right to the LCD module's 2x8 connector.

To further rule out hardware I will take the Mega shield and plug it into a solderless breadboard and hook up wires from the Duem/328 to prove the shield's pins to the LCD work.

And I have tested the I/O pins in question on the Mega, and they all work as outputs to blink an LED.

Hmmm.. is all I have to say at this time. And stay tuned.

LCD is working now on Mega.

The issue was my mistake, I had not grounded the LCD R/W pin the Mega shield I built hosting the LCD connection.