Interfacing 16×2 LCD With 8051
Interfacing 16×2 LCD With 8051
Valmik Dhanwate
very easy if you understanding the working of LCD.
Valmik Dhanwate
LCD module, the pin configuration us given below.
2
THE PIN CONFIGURATION
There are 16 pins in the LCD module
Valmik Dhanwate
3
STEPS :-
Follow these simple steps for displaying a character or data
E=1; enable pin should be high
Valmik Dhanwate
R/W=0; Read/Write pin should be low.
4
LCD COMMANDS :-
There are some preset commands which will do a specific task in the LCD.
These commands are very important for displaying data in LCD. The list of
commands given below:
Valmik Dhanwate
5
INTERFACING 16×2 LCD WITH 8051 CIRCUIT
DIAGRAM
Valmik Dhanwate
6
COMPONENTS REQUIRED
AT89C51 (8051 Microcontroller)
16X2 LCD Display
11.0592MHz Crystal
2 X 33pF Capacitors
Valmik Dhanwate
2 X 10 KΩ Resistors
1 KΩ X 8 Resistor Pack
10 KΩ Potentiometer
330Ω Resistor
Push Button
10μF/16V Capacitor
8051 Programmer
5V Power Supply
Connecting Wires 7
CIRCUIT EXPLANATION
The crystal oscillator, along with two 33pF Capacitors, are
connected to XTAL1 and XTAL2, which will provide the
system clock to the microcontroller.
RST Pin is pulled-LOW with the help of a 10KΩ Resistor.
Valmik Dhanwate
With the help of a 10μF Capacitor and a Push Button, you can
reset the 8051 Microcontroller. EA is pulled-HIGH with the
help of a 10KΩ resistor.
The data pins of the LCD are connected to PORT0 (first, the
PORT0 pins must be pulled-HIGH with the help of a 1KΩ
Resistor Pack). RS and E are connected to PORT2 pins P2.0
and P2.1.
A 10KΩ Potentiometer is used to adjust the contrast of the
LCD.
8
PROGRAMMING LCD TO 8051 :-
Coming to the programming you should follow these steps:
STEP1: Initialization of LCD.
Valmik Dhanwate
Initializing LCD :-
To initialize LCD to the 8051 the following instruction and
commands are to be embed in to the functions
0x38 is used for 8-bit data initialization.
Valmik Dhanwate
WRITING THE DATA TO THE LCD
E=1; enable pin should be high
10
CODE
#include<reg51.h>
#define lcd P2
sbit rs=P2^0;
sbit e=P2^1;
Valmik Dhanwate
11