本人使用的郭天祥老师的TX-1C
开发板
结果再做1602实验,结果下载程序后1602还是什么都木有,只有背光灯亮着
程序如下:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
sbit lcden=P3^4;
sbit rs=P3^5;
uchar num;
uchar code table[]=" 2013-2-20 ";
uchar code table1[]=" 00:00:00 ";
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
rs=0;
lcden=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_date(uchar date)
{
rs=1;
lcden=0;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
lcden=0;
dula=0;
wela=0;
num=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
for(num=0;num<16;num++)
{
write_date(table[num]);
delay(5);
}
write_com(0x80+0x40);
for(num=0;num<16;num++)
{
write_date(table1[num]);
delay(5);
}
}
void main()
{
init();
while(1);
}
求大神帮忙看看啊,找了好久就是不知道哪有问题,要崩溃了
一周热门 更多>