Anda di halaman 1dari 15

LCD Interfacing

USING 8051 C PROGRAMMING




BY VINAY KULKARNI
LCD
LCD (Liquid Crystal Display) screen is an electronic display module , A 16x2 LCD display is
very basic module and is very commonly used in various devices and circuits. We are
using the same in our experiments .
Characteristics of LCD display module .
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, namely, Command and Data.
The command register stores the command instructions given to the LCD.
A command is an instruction given to LCD to do a predefined task like
initializing it, clearing its screen, setting the cursor position,
controlling display etc.
The 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.
Pin Description
The steps that has to be done for initializing the LCD
display is given below and these steps are common for
almost all applications :
1.Send 38H to the 8 bit data line for initialization
2.Send 0FH for making LCD ON, cursor ON and cursor
blinking ON.
3.Send 06H for incrementing cursor position.
4.Send 01H for clearing the display and return the
cursor.

Sending Data to LCD
Make R/W low. // indicating write operation.
Make RS=0 if data byte is a command and make RS=1
if the data byte is a data to be displayed.
Place data byte on the data register.
Pulse EN from high to low. // EN=enable
Repeat above steps for sending another data.
#include<REG52.H>
sbit rs = P2^0; // Register Select
sbit rw = P2^1; // RW read write
sbit en = P2^2; //enable

void lcd_init()
{
lcd(0x38, 0); // Function Set
lcd(0x01, 0); // Clear LCD
lcd(0x0E, 0); // Display ON
lcd(0x06, 0); // Entry mode - Auto increment
}
void main(void)
{
unsigned char arr[15]={'S','D','M','C','E','T','C','S','E',' ','D','E','P','T'};
unsigned char i;
//initialization
lcd_init();
while(1)
{
lcd(0x80, 0); // Address of the first line in the LCD
for(i = 0; i <= 05; i++)
lcd(arr[i], 1);
lcd(0xc0, 0); // Address of the first line in the LCD
for(i = 06; i <= 13; i++)
lcd(arr[i], 1);
}
}

//funcion for command write into lcd
void lcd(unsigned char addr, bit flag)
{
P0 = addr;
rs = flag; //register control select
rw=0; //write enable
en=1;
en=0;
delay1(500);
en = 1;
}

void delay1 (unsigned int del)
{
while(--del);
}
For Further Reference check out :

http://www.dnatechindia.com/Tutorial/8051-Tutorial/Interfacing-LCD-to-
8051.html
http://www.pantechsolutions.net/project-kits/interfacing-lcd-with-8051
http://www.engineersgarage.com/microcontroller/8051projects/interface-
lcd-at89c51-circuit
http://www.circuitstoday.com/interfacing-16x2-lcd-with-8051
THANK YOU
VINAY KULKARNI

Anda mungkin juga menyukai