刚刚开始学LCD1602编了一个程序,但怎么不显示??
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table[]="I miss you!";/////第一行显示
uchar code table1[]="YOU!!";/////第二行显示
sbit lcden=P3^4; //////申明引脚
sbit lcdrs=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
uchar a,x;
void delayms(uint);
void delayms(uint xms) ///////延时
{
uint i,j;
for(i=xms;x>0;x--)
for(j=110;j>0;j--);
}
void write_com(uchar com) //////////命令操作
{
lcdrs=1;
P0=com;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void write_date(uchar date) /////////数据操作
{
lcdrs=1;
P0=date;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void init() //////////////初始化
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main() ////////////主函数
{
init();
write_com(0x80);
for(a=0;a<11;a++)
{
write_date(table[a]);
delayms(1000);
}
write_com(0x38+0x40);
for(a=0;a<5;a++)
{
write_date(table1[a]);
delayms(1000);
}
}
|