1. Dr. Vithalrao Vikhe Patil College of Engineering,
Ahmednagar
Department of Information Technology
Lecture on
Unit No 6
LCD Interfacing with 8051 Microcontroller
Processor Architecture & Interfacing (S.E.I.T.)
Presentation By
Prof. Ms. M. S. Gunjal
Department of Information Technology
2. Objectives
What is LCD
Pin diagram of LCD
Commands of LCD
Cursor Address of different LCD
Interfacing Diagram of LCD with 8051
Assembly language program of interfacing
April 23, 2020 2
3. LCD Stands for "Liquid Crystal Display."
LCD is a flat panel display technology
commonly used in TVs and computer monitors.
It is also used in screens for mobile devices,
such as laptops, tablets.
It has ability to display numbers, characters
and graphics.
LCD?
April 23, 2020 3
5. Pin Diagram Description
Pin Symbol I/O Descriptions
1 VCC ……. +5 volt power supply
2 VSS …….. Ground
3 VEE …… Power Supply to Contrast
4 RS I Register Select( 0 for command register and 1
for data register)
5 R/W# I 1 for Read
0 for write
6 E I/0 Enable
7-14 DB0-DB7 I/0 The 8-bit data bus
15 LED + …… Usually Connected t0 +5v of power supply
16 LED - ……. Connected to Ground
April 23, 2020 5
7. LCD Command Codes
Code
(Hex)
Command to LCD Instruction Register
1 Clear display screen
2 Return home
4 Decrement cursor (shift cursor to left)
6 Increment cursor (shift cursor to right)
5 Shift display right
7 Shift display left
8 Display off, cursor off
A Display off, cursor on
C Display on, cursor off
E Display on, cursor on
F Display on, cursor blinking
April 23, 2020 7
8. Continued….
Code
(Hex)
Command to LCD Instruction Register
10 Shift cursor position to left
14 Shift cursor position to Right
18 Shift the entire display to the left
1C Shift the entire display to the Right
80 Force cursor to beginning to 1st line
C0 Force cursor to beginning to 2nd line
38 2 lines and 5x7 matrix
April 23, 2020 8
12. Important Points while
Programming
A high to low pulse should be provided in an
enable pin for Write Operation
A low to high pulse should be provided in an
enable pin for Read Operation
Bit D7 of LCD is busy flag which can be used
to check if LCD is busy in its own internal
operation
Busy flag can be read when R/W =1 and
RS=0 and a L to H pulse in enable pin
April 23, 2020 12
14. Program
P1.0-p1.7 are connected to LCD data pins D0-D7
P2.0 is connected to RS pin of LCD
P2.1 is connected to R/W pin of LCD
P2.2 is connected to E pin of LCD
ORG 00H
MOV A,#38H ;init.LCD 2 Lines
ACALL COMMAND ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#0EH ; display on,cursor on
ACALL COMMAND ;call command subroutine
ACALL DELAY ; give LCD some time
MOV A,#01h ;clear LCD
ACALL COMMAND ; call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#06H ;shift cursor right
ACALL COMMAND ;call command subroutine
ACALL DELAY ;give LCD some time
April 23, 2020 14
15. Program Continue..
MOV A,#84H ;cursor at line 1,pos.4
ACALL COMMAND ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#’N’ ;display letter N
ACALL DATA1 ;call display subroutine
ACALL DELAY ;give LCD some time
MOV A,#’O’ ; display letter O
ACALL DATA1 ;call display subroutine
ACALL DELAY ;give LCD some time
Again:SJMP Again
COMMAND: MOV P1,A ;copy regi.A to port 1
CLR P2.0 ;RS=0 for command
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give some time LCD
CLR P2.2 ;E=0 for H-to –L pulse
RET
April 23, 2020 15
16. Program Continue…
DATA1: MOV P1,A ;write data to LCD
SETB P2.0 ;RS=1 for data
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give some time to LCD
CLR P2.2 ;E=0 for H to L pulse
RET
DELAY:MOV R3,#50H ;R3=50
HERE2:MOV R4,#255H ;R4=255
HERE:DJNZ R4,HERE ;decrement jump if not zero
DJNZ R3,HERE2
RET
END
April 23, 2020 16