LCD library using non sequential pins

Hi all,

Does the LCD library (LiquidCrystal) require you to sequential pins (for the data signals). I seem to remember with the original code the data pins had to be in order for it to work.

I’d like to use non sequential pins as it will help my board layout somewhat.

eg: will this work

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 12, 5, 2, 3, 4);

void setup()
{
lcd.print(“hello, world!”);
}

void loop() {}

Regards
cwhitto

Yes that is fine. I believe any combination of pins will be fine. If you look at the example codes for that library you will see they call for these pins:

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

As i understand it earlier versions of the LiquidCrystal library defined the pins inside the library itself limiting you on where you could place them. Could be wrong on that.

I did notice you have one extra pin number assigned there that isn't needed. First assignment goes to the Enable pin on the LCD, next is the RS pin, then comes DB7, DB6, DB5, and DB4. So as long as you list the pins in the right order your fine.

Thanks Mike,

yeah all the examples i could find had sequential pins used for the data pins, just like the example in your post.

I'll give it a try and see what happens.

Rgds Cwhitto

I did notice you have one extra pin number assigned there that isn't needed.

It IS needed if you want to use the R/W pin. In his example R/W should be connected to pin 9. Although the use of the R/W pin is not implemented in the current LiquidCrystal library it could still be used with some additional code if desired or required.

To answer the original question - the pins do NOT have to be sequential.

Don

Ok kewl.

I just thought the R/W pin was always tied to ground.

It might as well be for all the use that is made of it in the library. I hacked the library a bit to use the read / write pin to see when to write to the LCD instead of just putting delays in the code. I also predefined the pins and used direct port access to write out. The net result was that it took about half the time to output an 8 bit number on the display. Most of the speed up came from using the read command to see when it was not busy, especially in the clear and cursor home commands.

Having the output be faster is nice, but if you want to drive the LCD using only 8 wires (including power and ground), say using ethernet cable, then you need to cut something out.