Noobe needs help with LCD and "include"

I have just started learning about the Arduino and have bought an LCD shield off ebay. The card comes with 6 push buttons. There is an include code posted on the ebay site. I have no idea where and how to use this include. It took me 3 hours of Googling to find out why this shield wouldn’t work. It has different pin out then any of the tutorials. (8, 9, 4, 5, 6, 7) . I was unable to post the picture of the LCD sheild being this is my first post. Maybe I can in a reply.Thanks for any help Carl

#include <LCD4Bit_mod.h>

LCD4Bit_mod lcd = LCD4Bit_mod(2);

char GP2D12;
char a,b;
char str1[]="Renge:";
char str2[]="   Renge Over   ";
char str3[]="cm";

void setup()
  lcd.printIn("GP2D12 testing..."); 

void loop()
          lcd.cursorTo(2, 3); 

float read_gp2d12_range(byte pin)
  int tmp;
  tmp = analogRead(pin);
  if (tmp < 3)return -1; 
  return (6787.0 /((float)tmp - 3.0)) - 4.0;

Forget the lcd4bit library (the ‘include code’) its outdated and inefficient. Best bet is the included examples in the IDE. They will just need adjusting to suit the pinouts of your shield.

Starting with the infamous ‘Hello world’ is good.

  LiquidCrystal Library - Hello World
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 This sketch prints "Hello World!" to the LCD
 and shows the time.
  The circuit:
 * 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
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (
 example added 9 Jul 2009
 by Tom Igoe
 modified 25 July 2009
 by David A. Mellis

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  // adjust this to suit your pins.

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:

It still has an include, but at least the include is included… :wink:

Thanks for answering. I did try to include the include and only got errors that I don't yet understand. I was able to get the display working with pinout of 9, 8, 4, 5, 6, 7. I looked at the schematic of the Lcd and noticed the pinouts run from pin 1 to pin 16 of the LCD, Is that why the pin asignment runs 9 8 then 4567?

The lcd4bit library (like any external library) needs adding to the relevant folder in the IDE for it to work. The far superior liquidcrystal library is already installed as standard. A standard character LCD can be made to work on any combination of digital pins, the ones on your shield were probably chosen for convenience of manufacture as much as anything.

Starting with the infamous ‘Hello world’ is good.

In your case you want to change: LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

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


Changing the pin to 9 8 4 5 6 7 is just what I did to get it going. My question is why are the pin numbers 9 8 4 5 6 7 and not 4 5 6 7 8 9 ?

My question is why are the pin numbers 9 8 4 5 6 7 and not 4 5 6 7 8 9 ?

Because thats the way the manufacturers chose to wire the shield. Only they could answer that. There wouldn't be any reason they couldn't wire the shield like that so that it conformed to the liquidcrystal library.

One of my projects contains the line :

LiquidCrystal lcd(12, 2, 7, 8, 9, 10);

I chose those particular pins, because they could be spared on a pre-existing project and because they were easy to wire that way.

I have another project ( ) that contains the line :

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

It was because the hand made stripboard arduino board was easy to make with the pins wired like that...........


My question is why are the pin numbers 9 8 4 5 6 7 and not 4 5 6 7 8 9 ?

Its 8 9 4 5 6 7 ...

Because thats the way the manufacturers chose to wire the shield.

This is correct, but is only half of the answer. The other half was specified by the Arduino team and only they could answer why they chose what they did.

Here's a more detailed version of the answer to your question.

The LiquidCrystal library is invoked with a command having this syntax:


LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)

There are four versions and you must use the one corresponding to the interface that you are using. The first two are for the 4-bit data interface the first without and the second with the R/W line implemented. The LiquidCrystal library currently does not use the R/W line in either case so there is no benefit in implementing it. The third and fourth versions are similar to the first two but for the 8-bit data interface.

The important thing to note is the sequence of the pin names within the parentheses. This is the sequence that you must use - after you have selected the proper version depending on how your particular LCD is configured and/or wired.

Reply #2 links to a schematic which, in the upper right part, indicates that there are only six connections between the LCD and the Arduino. This means that the first version of the syntax must be used. It also shows that RS is connected to Arduino D8, E is connected to Arduino D9, DB4 is connected to Arduino D4, etc. This gives you the sequence of pin numbers to put within the parentheses.

so the generic:     LiquidCrystal(rs, enable, d4, d5, d6, d7) is implemented as:LiquidCrystal( 8,      9,  4,  5,  6,  7)


Thanks Don. I understand that. My first observation was the LCD pins used are 4,5, 11, 12, 13, 14. And that is the Arduino pins 8, 9, 4, 5, 6, 7. So the order in the code would run from pins 1 through 16 of the LCD. Just my first assumption. Carl


the LCD pins used are 4,5, 11, 12, 13, 14

Its 4,6,11,12,13,14

So the order in the code would run from pins 1 through 16 of the LCD.

Well they do, sort of. If you look at the last of the four syntax examples you will see that they run through pins 4 --> 14 of the LCD, in order. All of the other syntax examples are subsets of the last one, with various pins omitted. The remaining pins are still in order on the LCD. You can match them up with any pins that you care to on the Arduino.


I was running on only 2 hours sleep when I posted the question and might not have made my question clear. I was wundering why the CODE is writen with the pin numbers in that order not why the LCD board or Arduino PINS are used. Can the CODE be (4, 5, 6, 7, 8, 9)? Or will the CODE have to be (8,9,4,5,6,7). Same numbers just differant order.

You can use any of the Arduino pins in any order. You may want to avoid pins 0 and 1 since they are used by the serial port, but you don't have to.