#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table1[]="I LOVE YOU!!!";
uchar code table2[]="ha ha";
sbit lcde=P2^7;
sbit lcdrs=P2^6;
sbit lcdrw=P2^5;
uchar num;
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void write_com(uchar com)
{
lcdrs=0;
lcde=0;
lcdrw=0;
P0=com;
delayms(1);
lcde=1;
delayms(1);
lcde=0;
}
void write_data(uchar date)
{
lcde=0;
lcdrs=1;
lcdrw=0;
P0=date;
delayms(1);
lcde=1;
delayms(1);
lcde=0;
}
void init()
{
lcde=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void main()
{
init();
write_com(0x80);
for(num=0;num<13;num++)
{
write_data(table1[num]);
delayms(1);
}
write_com(0x80+0x40);
for(num=0;num<5;num++)
{
write_data(table2[num]);
delayms(1);
}
while(1);
}
编译无错误无警告,就是在lcd中不显示
|