How to interface 16x2 LCD using 8051/AT89c51.
LCD Interfacing Using 8051/89c51
Here I am writing program to interface LCD using 8051/AT89c51 Microcontroller. For interfacing a LCD you must have some idea about LCD Pins. The LCD which is normally available in market is of 16-pin.LCD pin description is explained below:-
PIN NUMBER
|
SYMBOL
|
FUNCTION
|
1.
|
VSS
|
GROUND
|
2.
|
VDD
|
+5V
|
3.
|
VEE
|
Contrast Adjustment
|
4.
|
RS
|
Register Selection Signal
|
5.
|
R/W
|
H/L , Read/write Signal
|
6.
|
E
|
H->L, Enable Signal
|
7.
|
D0
|
H/L ,Data Bus Line
|
8.
|
D1
|
H/L ,Data Bus Line
|
9.
|
D2
|
H/L ,Data Bus Line
|
10.
|
D3
|
H/L ,Data Bus Line
|
11.
|
D4
|
H/L ,Data Bus Line
|
12.
|
D5
|
H/L ,Data Bus Line
|
13.
|
D6
|
H/L ,Data Bus Line
|
14.
|
D7
|
H/L ,Data Bus Line
|
15.
|
A/VEE
|
Backlight Anode
|
16.
|
K
|
Backlight cathode
|
As per the pin details of LCD explained in above table the important pin used to display character on LCD are RS,R/W,E and 8- data lines (D0-D7) .Through RS pin we can select the LCD data register or LCD command register. If RS pin is HIGH then data register is selected or if RS pin is LOW then command register is selected. R/W is for selecting read or write operation if R/W pin is HIGH then read operation is selected if R/W pin is LOW then write operation is selected. Enable pin is to enabling data reception. Pin D0 to D7 are data lines through which LCD received command or data in 8-bit format.
Connection diagram used to interface LCD is given in below image:-
Now you can see in the connection diagram that RS is connected to P2.0 and R/W pin is ground for Write operation and Enable (E) pin is connected to P2.1.Also considered that data lines are connected to port 1.
In this Program I have print my name (VAIBHAV SINGHAL) in first line and my profession (i.e. FIRMWARE Engineer) in second line.the main file of program is shown in below image:-
In the image of above program you can see I have first initialized the LCD by sending commands, 0x38 for 2 lines and 5x7 matrix,0x0C to ON the display,0x01 to clear LCD screen and 0x06 for cursor increment. After initializing LCD i have write command to start writing from 1 line and send my name then send command to write data from second line i have wrote my profession.
Now in above program I have used to functions one to write command and the other is to send string on LCD. Definition of both function is given in image below:-
This is all about to write characters on 16x2 LCD by using 8 data lines.
Download Link
To download complete code of LCD interfacing using 8051/89c51 click here.
To download AT89c51 datasheet click on download tab.
To download AT89c51 hardwae mannual click on download tab.
No comments:
Post a Comment