Hitachi HD 44780 LCD controller is one of the most common used character LCD. It is available in variety of size such as 8×2, 16×2 or 20×4. This kind of LCD controller is easy to interface and there are also many libraries made for this controller.

DSC06789
Front view of 16×2 LCD
DSC06788
Back view of 16×2 LCD

So, lets start looking at the hardware of LCD. Some of the LCD comes with 14 pins while some are 16 pins. The extra two pins are used for backlight supply. There are 3 pins used as control pin namely register select (RS), read/write (RW) and enable (E). Besides that, there are 8 pins used as data line. Summary of the pins are as below:

lcd1
Pin description for HD 44780 controller

Note that there are 8 data pins available. So there are 2 kinds of interfacing available which is 8 bit interfacing and 4 bit interfacing. In 4 bit interfacing, the lower four bit (D0 – D4) are not in used.

lcd2
Circuit diagram of LCD and Arduino Uno

Below is the how I set up the LCD with the Arduino that I had on breadboard.

DSC06786

Example of code interfacing with LCD

#include <LiquidCrystal.h>
LiquidCrystal lcd(5,6,7,8,9,10);
void setup()
{
 lcd.begin(16,2);
}

void loop()
{
 lcd.clear();
 lcd.setCursor(1,0);
 lcd.print("Liquid Crystal");
 lcd.setCursor(4,1);
 lcd.print("Display");
 delay(2000);
 lcd.clear();
 lcd.setCursor(1,0);
 lcd.print("For more ");
 lcd.setCursor(1,1);
 lcd.print("details, visit");
 delay(2000);
 lcd.clear();
 lcd.setCursor(4,0);
 lcd.print("iamzxlee.");
 lcd.setCursor(2,1);
 lcd.print("wordpress.com");
 delay(2000);
}

Explanation of code:

At the beginning, you need to add the line #include <LiquidCrystal.h> to use the library for LCD.

 LiquidCrystal lcd(RS, Enable, D4, D5, D6, D7)

This is used to initialize the library with respective pins. In my case, I am using pin 5 to pin 10 for respective pins. So it would be LiquidCrystal lcd(5,6,7,8,9,10).

lcd.begin(column, row)

– This is used to initialize the lcd that you are using. In my case, I’m using a 16×2 LCD, so include it in the void setup() as lcd.begin(16,2).

– Without setting up this lcd.begin(), your lcd will only display on the first line.

lcd.setCursor(column, row)

– This is used to set the cursor at where you want to begin displaying your character.

lcd.print()

– This is used to type in what you want to display on the display, it can be a variable or a string of characters. For the case of variable, you can straight away type lcd.print(your variable here). However, if you want to display a string of characters, you need to include “Your text here”, example lcd.print(“Hello, world!”)

lcd.clear()

– This is used to clear all the display on the lcd

Last but not least, a video demo of using LCD. 🙂

Enjoy 😀

Advertisements