Interfacing LCD To Arduino
Interfacing LCD To Arduino
The name and functions of each pin of the JHD162A LCD module is given below.
Pin1(Vss):Ground pin of the LCD module.
Pin3(VEE):Contrast adjustment pin. This is done by connecting the ends of a 10K potentimeter
to +5V and ground and then connecting the slider pin to the VEE pin. The voltage at the VEE pin
defines the contrast. The normal setting is between 0.4 and 0.9V.
Pin4(RS):Register select pin.The JHD162A has two registers namely command register and data
register. Logic HIGH at RS pin selects data register and logic LOW at RS pin will select command
register. If we make the RS pin HIGH and put a data on the data lines (DB0 to DB7) it will be
recognized as a data. If we make the RS pin LOW and put a data on the data lines, then it will be
taken as a command.
Pin5(R/W): Read/Write modes. This pin is used for selecting between read and write modes.
Logic HIGH at this pin activates read mode and logic LOW at this pin activates write mode.
Pin6(E): This pin is meant for enabling the LCD module. A HIGH to LOW signal at this pin will
enable the module.
Pin7(DB0) to Pin14(DB7): These are data pins. The commands and data are put on these pins.
Pin15(LED+): Anode of the back light LED. When operated on 5V, a 560 ohm resistor should be
connected in series to this pin. In arduino based projects the back light LED can be powered from
the 3.3V source on the arduino board.
Circuit diagram.
RS pin of the LCD module is connected to digital pin 12 of the arduino. R/W pin of the LCD is
grounded. Enable pin of the LCD module is connected to digital pin 11 of the arduino. In this
project, the LCD module and arduino are interfaced in the 4-bit mode. That means only four of
the digital input lines( DB4 to DB7 of the LCD are used). This method is very simple, requires
less connections and you can almost utilize the full potential of the LCD module. Digital lines
DB4, DB5, DB6 and DB7 are interfaced to digital pins 5, 4, 3 and 2 of the Arduino. The 10K
potentiometer is used for adjusting the contrast of the display. 560 ohm resistor R1 limits the
current through the back light LED. The arduino can be powered through the external power jack
provided on the board. +5V required in some other parts of the circuit can be tapped from the 5V
source on the arduino board. The arduino can be also powered from the PC through the USB
port. The full program for interfacing LCD to arduino is shown below.
Program.
#include<LiquidCrystal.h>
void setup()
{
lcd.begin(16, 2); // initializes the 16x2 LCD
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("HELLO WORLD");
right and the functionlcd.scrollDisplayLeft() will scroll the display to left. A for loop is used for
selecting the number of positions to scroll at a time. In the program shown below, it is chosen to
be 2 because the text to be displayed is comparatively long. For shorter texts more number of
positions must be scrolled at a time to get a smooth display.
#include <LiquidCrystal.h>
int i=0;
void setup()
{
lcd.begin(16, 2);
void loop()
{
for(i=0;i<2;i++)
{lcd.scrollDisplayLeft();} //scrolls display left by two positions
delay(800);
}