Can I change the pins when I use the library LiquidCrystal

Hi,

I want to connect a display to my already existing circuit. My problem is that the pins D10 to D13 are already connected. Can I change the pin configuration of the library without problems or not?
Normal:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground

So I have to change pin 11 and 12, to which other pins I can connect them?

You should be able to use any pins available except 0 and 1 as long as you change the parameters when you create an instance of the LCD. Try changing the pin assignments in a simple program first such as the LiquidCrystal Hello World example.

Were you ever able to change the LCD pins by chance? I was wondering the same thing.

I was wondering the same thing.

Of course you can. That's why the pin numbers are input to the instance.

I often use:

LiquidCrystal lcd(12, 11, 9, 8, 7, 6); 	  // Setup the LCD hardware interface pins

for my LCD's. The reason is because the UNO uses 0 and 1 for the Serial object (as Bob pointed out) and pins 2 and 3 are used for external interrupt service routines. If you don't ISR's, pins 2 and 3 are usable, too.

econjack:
I often use:

LiquidCrystal lcd(12, 11, 9, 8, 7, 6);  // Setup the LCD hardware interface pins

for my LCD's. The reason is because the UNO uses 0 and 1 for the Serial object (as Bob pointed out) and pins 2 and 3 are used for external interrupt service routines. If you don't ISR's, pins 2 and 3 are usable, too.

I often use:

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // display pins

This cabling keeps free many useful pins like:
pin-0/1 used for Serial debugging
pin-2/3 which can be used for hardware interrupts
pin-10/11/12/13 which are the SPI pins on Atmega328 boards
pin-A4/A5 which are the I2C pins on Atmega328 boards

Of course, LCD cabling could use other pins, including the analog pins A0, A1, A2, ...

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

This configuration also has the advantage of matching the pin number arrangement of the common lcd button shields, and some sketches can be easily be shuffled around to use either the shield or standard display.

Hi guys, wondering the same thing as I want to put an EF02037 shield on top of my uno, but pin 0 and pin 7 aren't connected from the uno to the EF02037 shield.

My current line of code reads:

LiquidCrystal lcd(12,11,10,9,8,7,6,5,4,3,2);

I also notice I have 11 pins assigned above and you guys are using 6 pins.

Please help :slight_smile:

Andy

I also notice I have 11 pins assigned above and you guys are using 6 pins.

See this information on the Liquid Crystal Constructor

You have a complete "constructor" for 8 bit mode with a RW pin. That is very unusual, and most of the displays are run in 4 bit mode with the 6 pin constructor and RW grounded.

I want to put an EF02037 shield on top of my uno, but pin 0 and pin 7 aren't connected from the uno to the EF02037 shield.

My advice would be to use use the 6 pin constructor, and don't use pin 0 or 7, or any of the pins used by the function of the shield.

Thank you cattledog, I have gone to 4 bit data transfer on it and had it working on fine, but when I added another shield ontop (EF02037) and use the same pin connectors it just does this:

Is it possible the EF02037 shield is using some of the same pins?

Many thanks

Andy

Is it possible the EF02037 shield is using some of the same pins?

Very likely. The shield uses SPI which on a uno uses pins 11,12,13, and possibly 10.

ah, is that not what the 6 pin SPI connector is for at the end of the board? Sorry confused lol

andyb6:
ah, is that not what the 6 pin SPI connector is for at the end of the board? Sorry confused lol

Look at the schematic. The SPI pins are duplicated.

The SPI pins are parallel to the same pins on the edge of the board; see the schematic of the uno.

This is also the case for the I2C pins at the edge of the board (near pin 13) which are in parallel with A4 and A5.

Thank you guys, I changed the RS connection to pin 9 and the E (Enable) to pin 8 and updated the code line to suit:

const int rs = 9, en = 8, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

Uploaded it and still the same (just random characters on the screen), so I changed the text I had it display and uploaded again and it worked :slight_smile:

Very random but it works Thank you :slight_smile:

Edit: or at least it did lol. I guess I also have a loose connection somewhere, but at least I've seen it working :slight_smile:

Edit edit: I think I've tracked the issue down to a loose connection on the D4 connector.