Program For LCD and Keyboard Interface
Program For LCD and Keyboard Interface
#include<reg52.h>
sbit rs=P0^4;
sbit w=P0^5;
sbit e=P0^6;
sbit busy=P0^3;
void lcdinit();
void ready();
void keypad();
void main()
lcdinit();
command(0x80);
display(&msg1[0]);
command(0xC0);
display(&msg3[0]);
keypad();
}
void lcdinit()
//command(0x20);
command(0x28);
command(0x08);
command(0x01);
command(0x06);
return;
ready();
temp=com;
com=com>>4;
P0=com;
rs=0;
w=0;
e=1;
for(i=0;i<5;i++)
{}
e=0;
P0=temp;
rs=0;
w=0;
e=1;
for(i=0;i<5;i++)
{}
e=0;
return;
while(*ch!='\0')
ready();
data_display(*ch);
ch++;
temp=message;
message=message>>4;
P0=message;
rs=1;
w=0;
e=1;
for(i=0;i<5;i++)
{}
e=0;
P0=temp;
rs=1;
w=0;
e=1;
for(i=0;i<5;i++)
{}
e=0;
return;
void ready()
unsigned char i;
busy=1;
rs=0;
w=1;
while(busy==1)
e=0;
for(i=0;i<100;i++)
{}
e=1;
return;
}
void keypad()
unsigned int k;
unsigned char msg2[16]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
P1=0xFF;
P3=0x00;
temp=0xFE;
while(1)
P3=temp;
if(col!= 0x0F)
tempcol=col;
temprow=row;
for(k=0;k<8000;k++)
col=P1 &0x0F;
if(col==tempcol)
switch(col)
break;
case 0x0D: key=1;
break;
break;
break;
key=(key*4);
switch(row)
break;
break;
break;
break;
key=key+key2;
command(0x0C);
if(g==0xcf)
g=0xc3;
else
command(g);
g=g+1;
data_display(msg2[key]);
}
i++;
if(i==4)
temp=0xFE;
i=0;
else
temp=(temp<<1)+1;