How to interface LCD with Microcontroller

How to interface LCD with Micro-controller? LCD Liquid Crystal Display is commonly used in the electronic display module. 16×2 LCD is used for wide range of micro-controller applications. It can display 2 lines of 16 characters and each character is displayed using 5×7 pixel matrix.
lcd +mcu
LCD INTERFACING MODES:
LCD can be interfaced with micro-controller in
1. 4 Bit Mode.
In 4 Bit mode use only 4 lines data pins D4 to D7. Here 8 bit character ASCII data and command data are divide into two parts and send sequentially through date lines.operation speed is slow, but save micro-controller pins. Commonly used 4 bit mode operation.
2. 8 Bit Mode.
in 8 Bit mode to write a character, the 8 bit ASCII date is send through the date lines D0 to D7 and date strobe is give to Enable pin of the LCD.


LCD Applications:
1. To create custom characters.
2. To create animated characters.
3. Easy to interface with MCU than 7 Segment Display.
4. Calculators.
5. Laptops.
6. Mobile Phones.
PROGRAM FOR LCD INTERFACE WITH YOUR NAME.
#include<REG51.h>
#define cmdport P2
#define dataport P3
sbit rs = cmdport^5; //register select
sbit rw = cmdport^6; // read write
sbit e = cmdport^7; //enable
void delay(unsigned int msec) //Time delay
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void lcdcmd(unsigned char item) //Send command to LCD
{
dataport = item;
rs= 0;
rw=0;
e=1;
delay(1);
e=0;
}
void lcddata(unsigned char item) //Send data to LCD
{
dataport = item;
rs= 1;
rw=0;
e=1;
delay(1);
e=0;
}
void display(unsigned char *item)
{
int x;
for(x=0;item[x]!=0;x++)
{

lcddata(item[x]);
}
}
void main()
{
lcdcmd(0x38); // 8-bit 2 row mode
delay(100);
lcdcmd(0x0E); // display ON and cursor blinking
delay(100);
lcdcmd(0x01); //Clear screen
delay(100);
lcdcmd(0x06); //Display ON
delay(100);

while(1)
{
display(“Type your Name”);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *