Você está na página 1de 11

MGMCET

BME DEPARTMENT

MAHATMA GANDHI MISSIONS

COLLEGE OF ENGINEERING AND TECHNOLOGY


KAMOTHE, NAVI-MUMBAI-410209

DEPARTMENT OF BIOMEDICAL ENGINEERING


Microcontroller & Embedded Systems
TOPIC :- LCD INTERFACING WITH 8051
MICROCONTROLLER(AT89C51)

Submitted By:1)Safwan Ahmed Zuber Ahmed Shaikh


2)Sneha Chandrashekhar Singh
3)Keval Ramesh Dalbhanjan
Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

ACKNOLEGEMENT
We wish to express our
profound thanks to those Who helped in making this
project a reality. Much needed support and help is
provided by some of our seniors. We would like to
thank Prof. Preeti Athavale Whose suggested the
right subject and guided us to make this Project
successful. We also wish to thank Hanif Sir for
encouraging

and

supporting

us

on

occasions.

Microcontroller & Embedded Systems (VI-CBSGS)

numerous

MGMCET

BME DEPARTMENT

LCD Interfacing with 8051 Microcontroller(AT89C51)


LCD display is an inevitable part in almost all embedded projects and this article is about
interfacing 162 LCD with 8051 microcontroller.

LCD pin descriptions:


The LCD discussed in this section has 14 pins. The function of each pin is given in table.
Pin
1
2
3
4
5
6
7
8
9
10
11
12

Symbol
VSS
VDD(VCC)
VEE
RS
R/W
E
DB0
DB1
DB2
DB3
DB4
DB5

I/O
I
I
I/O
I/O
I/O
I/O
I/O
I/O
I/O

Description
Ground
+5V power supply
Contrast control
command/data register selection
write/read selection
Enable
The 8-bit data bus
The 8-bit data bus
The 8-bit data bus
The 8-bit data bus
The 8-bit data bus
The 8-bit data bus

Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

13
14

DB6
DB7

BME DEPARTMENT

I/O
I/O

The 8-bit data bus


The 8-bit data bus

Vcc, Vss, and VEE


While Vcc and Vss provide +5V and ground, respectively, VEE is used for controlling
LCD contrast.
RS - register select:
There are two very important registers inside the LCD. The RS pin is used for their selection
as follows. If RS = 0, the instruction command code register is selected, allowing the
user to send a command such as clear display, cursor at home, etc. If RS = 1 the data register is
selected, allowing the user to send data to be displayed on the LCD.

R/W - read/write:
R/W input allows the user to write information to the LCD or read information from it.
R/W = 1 when reading; R/W =0 when writing.
E - enable:
The 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 in order for the LCD to
latch in the data present at the data pins. This pulse must be a minimum of 450 ns wide.
D0 D7:
The 8 bit data pins, D0 D7, are used to send information to the LCD or read the contents
of the LCDs internal registers.
To display letters and numbers, we send ASCII codes for the letters A Z, a z, and
numbers 0 9 to these pins while making RS = 1.

Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

There are also instructions command codes that can be sent to the LCD to clear the
display or force the cursor to the particular position

Code (hex)
1
2
4
5
6
7
8
A
C
E
F
10
14
18
1C
80
C0
38

Command to LCD Instruction Register


Clear display screen
Return home
Shift cursor to left
Shift display right
Shift cursor to right
Shift display left
Display off, Cursor off
Display off, Cursor on
Display on, cursor off
Display on, cursor blinking
Display on, cursor blinking
Shift cursor position to left
Shift cursor position to right
Shift the entire display to the left
Shift the entire display to the right
Force cursor to beginning of 1st line
Force cursor to beginning of 2nd line
2 lines and 5x7 matrix

Schematic Diagram of LCD interfacing with 8051

Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

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

Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

Write a program to display HELLO.


ORG 00H
MOV A,#38H

ACALL COMNWRT
ACALL DELAY

MOV A,#0EH

ACALL COMNWRT
ACALL DELAY
MOV A,#01

;
;

ACALL COMNWRT
ACALL DELAY

MOV A,#06H

ACALL COMNWRT
ACALL DELAY

MOV A,#84H

ACALL COMNWRT
ACALL DELAY
MOV A,#'H'

;
;

ACALL DATAWRT
ACALL DELAY
MOV A,#'E'

;
;

ACALL DATAWRT
DELAY

; ACALL

MOV A,#'L'

ACALL DATAWRT
ACALL DELAY

;
;

Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

MOV A,#'L'

ACALL DATAWRT
ACALL DELAY

;
;

MOV A,#'O'

ACALL DATAWRT

AGAIN: SJMP AGAIN ;


COMNWRT:

MOV P1,A

CLR P2.0

CLR P2.1

SETB P2.2

ACALL DELAY
CLR P2.2

RET
DATAWRT:
MOV P1,A

SETB P2.0

CLR P2.1

SETB P2.2

ACALL DELAY
CLR P2.2

RET
DELAY: MOV R3,#50 ; HERE2:
MOV R4,#255 ;
HERE: DJNZ R4,HERE ; DJNZ
R3,HERE2
RET
END

Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

Program in Keil:-

1)

2)
Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

Connection in Proteus:-

Microcontroller & Embedded Systems (VI-CBSGS)

MGMCET

BME DEPARTMENT

Microcontroller & Embedded Systems (VI-CBSGS)

Você também pode gostar