#include
unsigned char table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char table2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
sbit weixuan=P2^3;//位锁存
sbit duanxuan=P2^2;//段锁存
void delay(unsigned char a)
{
while(a--);
}
void main()
{
unsigned char i;
while(1)
{
for(i=0;i<8;i++)
{
weixuan=1;
P0=table2[i];
weixuan=0;
duanxuan=1;
P0=table1[i];
duanxuan=0;
delay(200);
}
}
} |