Introduction about LED interfacing
Advantages of LCD over LED
wDeclining prices of LCD.
wAbility to display numbers, characters and graphics.
wEase of programming for characters and graphics.
wRelieving CPU from refreshing task of LCD
Pin Description
Pin No Description
w1 Vss
w2 Vcc
w3 Contrast Voltage
w4 RS
w5 R/W
w6 EN
w7-14 Data Input/Output Pins (D0-D7)
w15 Anode (K)
w16 Cathode (K)
w1) Vss- Vss is connected to the ground.
w2) Vcc- Vcc is connected to +5V.
w3) Contrast Voltage- Vee is used for controlling LCD Contrast. Variable pin of Variable Resistor of 10K is connected to this pin.
w4) RS- RS is used for the selection of internal resistors of LCD.
wCommand Code Register – It allows the user to send command such as clear display, cursor at home etc.
wData Register – It allows the user to send data to be displayed on LCD.
If RS=0, then Command Register is selected.
If RS=1, then Data Register is selected.
w5) R/W- R/W input allows user to write information to the LCD or read information from it.
R/W=1 when Reading
R/W=0 when Writing
w6) EN- This enable pin is used by the LCD to latch information presented to its data pins.
When data is supplied to data pins, a High-to-low pulse must be applied to this pin.
w7) Pin 7-14 – The 8-bit data pins, D0-D7 are used to send information to LCD or read the contents of the LCD’s internal registers.
To Display letters and numbers, ASCII codes for letters and numbers are sent to these pins while making RS=1.
Table of LCD Control Signals
Hardware Connection of 8051 With LCD
LCD Command Codes
Code Command to LCD Instruction register
(Hex)
w01 Clear display screen
w02 Return home
w04 Decrement cursor (shift cursor to left)
w06 Increment cursor (shift cursor to right)
LCD Command Codes
Code Command to LCD Instruction register
(Hex)
w08 Display off, cursor off
w0A Display off, cursor on
w0C Display on, cursor off
w0E Display on, cursor on
LCD Commands Codes
Code Command to LCD Instruction register
(Hex)
w0F Display on, cursor blinking
w80 Force cursor to beginning of 1st line
wC0 Force cursor to beginning of 2nd line
w38 2 Lines and 5x8 matrix
w30 1 Line and 5x8 matrix
Program for writing Command to LCD
mov P2,a
clr RS
clr R/W
setb EN
clr EN
acall busy
Program for writing Data to LCD
mov P2,a
setb RS
clr R/W
setb EN
clr EN
acall busy
Routine for checking LCD Busy state
busy: setb D7
back: setb EN
clr EN
jnb D7, back
ret
LCD Initialising Routine
mov a,#38h
acall command
mov a, #0eh
acall command
mov a,#01h
acall command
mov a,#06h
acall command
Contd…
mov a,#80h
acall command
mov a,#’J’
acall data
mov a,#’A’
acall data
mov a,#’J’
acall data