UNDERSTANDING THE HD44780 DISPLAY CONNECTION TO ARDUINO UNO

Many have asked me "How do the Display connect to ARDUINO UNO ?" - or "How does it work ?".

Here, I try to make it clear...

First of all, be sure you have the right Library installed, but to use a standard LCD-Display, the file "LCD.h"
is already a part of the library in the Arduino IDE

Next, you would normaly only use 4 data configuration, and NOT 8 data. 4 data is D4, D5, D6, D7 on the Display.
This code would be the declaration and pin-definition of your standard Display:

#include <LiquidCrystal.h>

/////////////////////////////////////////////////
// select the pins used on the LCD panel       //
// **********************************************
// ** LiquidCrystal lcd(RS, E, D4, D5, D6, D7) ** 
Understanding these two lines...
// **********************************************
// select ARDUINO-PIN-no:
LiquidCrystal lcd(
2, 3, 5, 6, 7, 8 );             is for many people the bigest problem
// **********************************************
// *** END of pin- assignment **
// **********************************************

// ********** Defining the DISPLAY **************
// ** Display is 20 character pr line **
// ** Display have 4 lines **
// **********************************************
const int colums = 20;  // have to be 16 or 20, but could be other size - first colum is no. 0 true 19
const int rows = 4;     // have to be 2 or 4, first line is no. 0 true 3
// **********************************************
// *** END of DISPLAY definition **
// **********************************************


This line:

// ** LiquidCrystal lcd(RS, E, D4, D5, D6, D7) **

is only comment in the program: "//", and tell you which port on the display you must use, and in which order.
This line tells you, the name of pins on the display.

You can change to other pins on Arduino UNO, after your ovn selection.

HD44780 - DISPLAY ARDUINO UNO
RS = Reg. Select     - pin 4
E  = Enable          - pin 6
D4 = Data 4          - pin 11
D5 = Data 5          - pin 12
D6 = Data 6          - pin 13
D7 = Data 7          - pin 14

DIGITAL pin 2
DIGITAL pin 3
DIGITAL pin 5
DIGITAL pin 6
DIGITAL pin 7
DIGITAL pin 8

Allways remember, that PIN 5 - Read/Write have permanent GROUND (GND) for writing to the display.

Look at the pins in this picture:

HD44780 Character LCD Displays

The next line, Definition-line:
    LiquidCrystal lcd( 2, 3, 5, 6, 7, 8 );
is the normal programming C-line, telling witch port to use on your Arduino UNO, and in the same order as described for the Display,
BUT... you can change wicth port you want to use on the Arduino UNO, not nessesary the port-nr. on this exampel!

First word "LiquidCrystal" reffers to the LIBRARY-file LiquidCrystal.h.
Next word "lcd" is the keyworddefinition for writing to the display in the pin-order in the breackets.
When the order is declared, the Library-file takes care of the lcd-commands like " lcd.setCursor(x,y); " or " lcd.print(" Hello world"); ", og "lcd.clear();".

Now...
Program-line could look like this in the ARDUINO IDE:

#include <LiquidCrystal.h>
LiquidCrystal lcd( 2, 3, 5, 6, 7, 8 );   // lcd-definitionline - Use digital Pins...
const int colums = 20;        // have to be 16 or 20, 
                              // but could be other size - first colum is no. 0 true 19 horisontal
const int rows = 4;           // have to be 2 or 4, first line is no. 0 true 3 vertical
int x;                        // x is the nr. position on the rows
int y;                        // y is the first of 4 rows - 0 true 3

void setup() {                // put your setup code here, to run once:
  lcd.begin(colums,rows);
  lcd.
clear();                // clear display
}

void loop() {                 // put your main code here, to run repeatedly:
  x = 0;                    
  // set the colums
  y = 0;                    
  // set the rows
  lcd.
setCursor( x, y );      // First poss. on rows 0
  lcd.
print("Hello world");   // Print...
}
                             // END og loop

From here...

Find the Digital Pins, numered as 0 true 13 just here under:

You can use these in any order you like, but you have to match the lcd-definition line.


Print a messages at a specific position - Like this:   LCDPrint("Hello World ", x, y );
... continue from start of "setup":

void setup() {      // put your setup code here, to run once:

  byte x = 5;   // x is the nr. poss. on the rows = 0 true 19
  byte y = 1;          // y is the first of 4 rows - 0 true 3
  lcd.begin(colums,rows); 
  lcd.clear();
  delay(200);   // wait for lcd-display to start up properply
}                                             // END of setup
//***********************************************************
void loop() {
  x = 5; y = 0; 
  LCDPrint("Hello World    ", x, y ); 
  delay(2000);
  LCDPrint("                  ", x, y);         // clear line
  LCDPrint("AND it WORKS!!!");
  delay(2000);
  lcd.clear();
}                                              // END og loop
//***********************************************************
// print a string at specified position x,y
//***********************************************************
void LCDPrint(char *str, byte column, byte row) {
  lcd.setCursor(column, row);
  lcd.print(str);
}                                           // END of Print 1
//***********************************************************
// print a string at cursor position
//***********************************************************
void LCDPrint(char *str) {
while (*str)
  {
    lcd.print(str);
    break;         // Without "break;" the program is LOOPING
  }
}                                            // END of Print2
//***********************************************************

Look at a DEMO on YOUTUBE: https://www.youtube.com/watch?v=QLmY5pJWdJ8&feature=youtu.be

THATS IT...
Hope you Injoy...
VY 73 de OZ6YM