#include<reg51.h>
sbit lcden=P2^7;
#define lcd P0
sbit rw=P2^5;
sbit rs=P2^6;
#define uint unsigned int
#define uchar unsigned char
void delay(z);
uchar i;
void write_com(com);
void write_date(date);
void init();
uchar code yi[14]="12345678901234";
uchar code er[13]="1234567890123";
void main()
{
init();
write_com(0x80);
for(i=0;i<14;i++)
{
write_date(yi[14]);
delay(5);
}
write_com(0x80+0x40);
for(i=0;i<13;i++)
{
write_date(er[13]);
delay(5);
}
while(1);
}
void init()
{
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void write_com(uchar com)
{
rs=0;
rw=0;
lcd=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_date(uchar date)
{
rs=1;
rw=0;
lcd=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>