动态数码管,滚动显示日期!
#include<REGX51.h>
void main(void)
{
const unsigned char design[17]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff};
unsigned char DisplayBuffer[24]={16,16,16,16,16,16,16,16,2,0,1,7,0,3,2,2,16,16,16,16,16,16,16,16};
unsigned int a;
unsigned char b;
unsigned char w;
unsigned char n;
unsigned char j;
do{
for(n=1;n<17;n++)
{
for(j=1;j<20;j++)
{
w=1;
for(b=0;b<8;b++)
{
for(a=0;a<500;a++); //延时一段时间
P0=255; //灭显示
P2=~design[DisplayBuffer[b+n]];
P0=~w;
w=w<<1; //逻辑左移
}
}
}
}while(1);
}
|