About LCD and Its Interfacing

Electronic Display are important Devices used in the field of Robotics and Embedded System and its devices. the display Seven Segments, LCD (Liquid Crystal Display) can be used to display Data .  The reasons being: LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on. LCD can be easily interfaced with a microcontroller to display a message or status of a device. They are of many types. The ones we commonly use for embedded systems, robotics, etc are of two types – character LCD and graphical LCD. lcd162b-yhy

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5×7 pixel matrix. This LCD has two registers.

  • Command/Instruction Register - stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing, clearing the screen, setting the cursor position, controlling display etc
  • Data Register - stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.

 

lcd cammand

 

Now the Pin Map

rgblcd_pinout

Lcd_0

  •  Data pin8 (DB7) of the LCD is busy flag and is read when R/W = 1 & RS = 0. When busy flag=1, it means that LCD is not ready to accept data since it is busy with the internal operations. Therefore before passing any data to LCD, its command register should be read and busy flag should be checked.
  •  To send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data is sent. Each write operation is performed on the positive edge of the Enable signal.
  •   To send a command on the LCD, a particular command is first specified to the data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent.

 

Arduino Liquid Crystal Library LCD Interface

Requirements :-

  • LCD 16×2
  • 1 Potentiometer
  • Jumperwire
  • Arduino Board
  • Bread board
  • Usb wire
  • Arduino IDE
  • Battery

 

All the product you can Buy From here

In this tutorial you will control a Liquid Crystal Display (LCD) using the Arduino LiquidCrystal library. The library provides functions for accessing any LCD using the common HD44780 parallel interface chipset, such as those available from Sparkfun.It currently implements 8-bit control and one line display of 5×7 characters. Functions are provided to initialize the screen, to print characters and strings, to clear the screen, and to send commands directly to the HD44780 chip. This tutorial will walk you through the steps of wiring an LCD to an Arduino microcontroller board and implementing each of these functions.

Install the Library
For a basic explanation of how libraries work in Arduino read the library page. Download the LiquidCrystal library here. Unzip the files and place the whole LiquidCrystal folder inside your arduino-0004\lib\targets\libraries folder. Start the Arduino program and check to make sure LiquidCrystal is now available as an option in the Sketch menu under “Import Library”.

Connect Pin Out of arduino to LCD

The pinout is as follows:
Arduino                    LCD
2                             Enable
3                             Data Bit 0 (DB0)
4                             (DB1)
5                             (DB2)
6                             (DB3)
7                             (DB4)
8                             (DB5)
9                             (DB6)
10                           (DB7)
11                           Read/Write (RW)
12                           Register Select (RS)

Connect a potentiometer a a voltage divider between 5V, Ground, and the contrast adjustment pin on your LCD.

LCDAR

 

Program

 

#include <LiquidCrystal.h> //include LiquidCrystal library
LiquidCrystal lcd = LiquidCrystal(); //create a LiquidCrystal object to control an LCD
void setup(void){
lcd.init(); //initialize the LCD
digitalWrite(13,HIGH); //turn on an LED for debugging
}
void loop(void){
lcd.clear(); //clear the display
delay(1000); //delay 1000 ms to view change
lcd.print(‘a’); //send individual letters to the LCD
lcd.print(‘b’);
lcd.print(‘c’);
delay(1000);//delay 1000 ms to view change
}

 

This is all great fun, but who really wants to type out each letter of a message indivually? Enter the printIn() function. Simply initialize a string, pass it to printIn(), and now we have ourselves a proper hello world program.
#include <LiquidCrystal.h> //include LiquidCrystal library
LiquidCrystal lcd = LiquidCrystal(); //create a LiquidCrystal object to control an LCD
char string1[] = “Hello!”; //variable to store the string “Hello!”
void setup(void){
lcd.init(); //initialize the LCD
digitalWrite(13,HIGH); //turn on an LED for debugging
}
void loop(void){
lcd.clear(); //clear the display
delay(1000); //delay 1000 ms to view change
lcd.printIn(string1); //send the string to the LCD
delay(1000); //delay 1000 ms to view change
} //repeat forever
Finally, you should know there is a lot of functionality in the HD44780 chip interface that is not drawn out into Arduino functions. If you are feeling ambitious glance over the datasheet and try out some of the direct commands using the commandWrite() function. For example, commandWrite(2) tells the board to move the cursor back to starting position. Here
is an example:
#include <LiquidCrystal.h> //include LiquidCrystal library
LiquidCrystal lcd = LiquidCrystal(); //create a LiquidCrystal object to control an LCD
char string1[] = “Hello!”; //variable to store the string “Hello!”
void setup(void){
lcd.init(); //initialize the LCD
digitalWrite(13,HIGH); //turn on an LED for debugging
}
void loop(void){
lcd.commandWrite(2); //bring the cursor to the starting position
delay(1000); //delay 1000 ms to view change
lcd.printIn(string1); //send the string to the LCD
delay(1000); //delay 1000 ms to view change
} //repeat forever