EXPERIMENT NO.
01
INTERFACING LCD WITH 8051 AND
DISPLAYING HELLO
DOP: DOS:
Project Members:
1) Prasad Pawaskar 58
2) Vishal Thakur 72
1
AIM: To interface LCD using 8051 microcontroller and displaying
characters (AT89C51).
Tools: Keil uVision 4, ISIS Proteus 7
Theory: It is very important to keep a track of the working of almost all
the automated and semi-automated devices, be it a washing
machine, an autonomous robot or anything else. This is achieved
by displaying their status on a small display module. LCD (Liquid
Crystal Display) screen is such a display module and a 16x2 LCD
module is very commonly used. These modules are replacing
seven segments and other multi segment LEDs for these purposes.
The reasons being: LCDs are economical, easily programmable,
have no limitation of displaying special & even custom characters
(unlike in seven segments), animations and so on. LCD can be
easily interfaced with a microcontroller to display a message or
status of a device. This topic explains the basics of a 16x2 LCD
and how it can be interfaced with AT89C51to display a character.
A 16x2 LCD means it can display 16 characters per line and there
are 2 such lines. In this LCD each character is displayed in 5x7
pixel matrix. This LCD has two registers.
1. Command/Instruction Register- stores the command
instructions given to the LCD. A command is an instruction given
to LCD to do a predefined task like initializing, clearing the
screen, setting the cursor position, controlling display etc.
2. Data Register- stores the data to be displayed on the LCD. The
data is the ASCII value of the character to be displayed on the
LCD
The AT89C51 is a low-power, high-performance CMOS 8-bit
microcomputer with 4K bytes of Flash programmable and
erasable read only memory (PEROM). The device is
manufactured using Atmel’s high-density non-volatile memory
technology and is compatible with the industry-standard MCS-51
instruction set and pin-out. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional
non-volatile memory programmer. By combining a versatile 8-bit
CPU with Flash on a monolithic chip, the Atmel AT89C51 is a
powerful microcomputer which provides a highly-flexible and
cost-effective solution to many embedded control applications.
2
Algorith Firstly, initialize all the ports.
m: Initialize the LCD to turn it ON and to a form that it is
ready to accept commands.
Now command the LCD to write.
Display the contents using the required functions.
Code: // C Program to interface LCD with 8051 and displaying
characters.
#include<reg52.h>
//including sfr registers for ports of the controller
#include<lcd.h>
//LCD Module Connections
sbit RS = P0^0;
sbit EN = P0^1;
sbit D0 = P2^0;
sbit D1 = P2^1;
sbit D2 = P2^2;
sbit D3 = P2^3;
sbit D4 = P2^4;
sbit D5 = P2^5;
sbit D6 = P2^6;
sbit D7 = P2^7;
//End LCD Module Connections
void Delay(int a)
int j;
int i;
3
for(i=0;i<a;i++)
for(j=0;j<100;j++)
void main()
int i;
Lcd8_init();
while(1)
Lcd8_Set_Cursor(1,1);
Lcd8_Write_String("ElectroSome Hello");
for(i=0;i<15;i++)
Delay(1000);
Lcd8_Shift_Left();
for(i=0;i<15;i++)
Delay(1000);
Lcd8_Shift_Right();
4
}
Lcd8_Clear();
Lcd8_Set_Cursor(2,1);
Lcd8_Write_Char('e');
Lcd8_Write_Char('S');
Delay(3000);
Output :
Conclusi Thus, interfacing LCD with AT89C51 and displaying characters
on: was simulated using proteus with the help of keil. The result were
visually verified using Run feature in proteus.