Exp No 3
Exp No 3
Exp No 3
OBJECTIVES
To interface 16x2 LCD display with 8051 microcontroller and to enable it for displaying
different characters.
THEORY
Keil C does not have powerful libraries for 16x2 LCD interfacing. Hence LCD library must be
developed with common features. Header file lcd.h must include the sub-program for LCD functions.
LCD can be interfaced with microcontroller in 4 Bit or 8 Bit mode. This differs in how data is send to
LCD. In 8 bit mode to write a character, 8 bit ASCII data is send through the data lines D0 – D7 and data
strobe is given through E of the LCD. But 4 Bit Mode uses only 4 data lines D4 – D7. In this mode 8 bit
character ASCII data and command data are divided into two parts and send sequentially through data
lines. 4 bit communication is used save pins of microcontroller but it is slower than 8 bit communication.
ALGORITHMS
Step1: Include a header file to assign special function registers for ports of the microcontroller
Step2: Include a header file for LCD i.e. lcd.h
Step3: Assign LCD module connections to ports of the controller. Example: sbit RS = P0^0;
Step4: Use sub-routines for invoking delay
Step5: Use special functions of LCD in main program
Step6: For 4 bit LCD interface, use LCD4 instead of LCD8 functions
Functions Description
Lcd8_Clear() Clear the LCD screen
Lcd8_Set_Cursor() To set the cursor position on the LCD screen
Lcd8_Write_Char() To write a character
Lcd8_Write_String() To write a string
Lcd8_Shift_Left() Shift display left without changing the data in display RAM
Lcd8_Shift_Right() Shift display right without changing the data in display
INTERFACING DIAGRAM:
PROGRAM:
RESULT
Thus the 16x2 LCD display is interfaced with 8051 microcontroller and different
characters was displayed and verified