科技学科吧 关注:12贴子:81
  • 0回复贴,共1
#include <reg51.h>
#define uchar unsigned char
sbit a=P2^7;
sbit b=P2^6;
sbit c=P2^5;
sbit d=P2^4;
uchar tab[]={0x22,0xaf,0x31,0x25,0xac,0x64,0x60,0x2f,0x20,0x2c};
uchar tac[]={0xfe,0xfd,0xfb,0xf7};
unsigned int a1,a2,a3,a4;
void delay(int t)
{
uchar i;
while(t--)
{
i=80;
while(i--);
}
}
void main()
{unsigned int i;
for(i=0;i<10000;i++)
{ a1=i/1000;
a2=i/100%10;
a3=i/10%10;
a4=i%10;
P2=0xfe;
P0=tab[a1];
delay(10);
P2=0xfd;
P0=tab[a2];
delay(10);
P2=0xfb;
P0=tab[a3];
delay(10);
P2=0xf7;
P0=tab[a4];
delay(10);
}
}


IP属地:浙江1楼2014-05-20 22:46回复