Google

Thursday, November 11, 2010

LCD interfacing with 8051 program

#include
sfr ldata=0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
void delay(unsigned int itime);
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);

char *name1="welcome to IIT-Madras power electronics group";
char *name2="and this is sekhar";
int m=0,n=0;

void main()
{
lcdcmd(0x38);
delay(250);
lcdcmd(0x0e);
delay(250);
lcdcmd(0x01);
delay(250);
lcdcmd(0x06);
delay(250);
lcdcmd(0x81);
delay(250);
while(name1[m]!='\0')
{
lcddata(name1[m++]);
delay(250);
}
lcdcmd(0xc1);
delay(250);
while(name2[n]!='\0')
{
lcddata(name2[n++]);
delay(250);
}
}

void lcdcmd(unsigned char value)
{
ldata=value;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcddata(unsigned char value)
{
ldata=value;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<=itime;i++)
for(j=0;j<=1275;j++);
}