本帖最后由 gonglong 于 2013-10-8 22:12 编辑
#include<reg51.h>
unsigned char table[]="dang pian ji";
sbit leden=P2^7;
sbit ledrs=P2^6;
sbit ledwr=P2^5;
void delay(unsigned int c)
{
unsigned int b;
for(;c>0;c--)
for(b=199;b>0;b--);
}
void writecom(unsigned char com)
{
leden=0;
ledrs=0;
ledwr=0;
P0=com;
delay(1);
leden=1;
delay(1);
leden=0;
}
void writedate(unsigned char date)
{
leden=0;
ledrs=1;
ledwr=0;
P0=date;
delay(1);
leden=1;
delay(1);
}
void init()
{
writecom(0x38);
writecom(0x0c);
writecom(0x06);
writecom(0x01);
writecom(0x80);
}
void main()
{ unsigned int i;
init();
writecom(0x80);
while(1)
{
for(i=0;i<12;i++)
{
writedate(table);
delay(10);
}
}
}
|