#include<reg52.h>
sbit du=P2^6;
sbit we=P2^7;
sbit fm=P2^3;
char code smg[17]={0x3f , 0x06 , 0x5b ,0x4f , 0x66 , 0x6d ,0x7d ,
0x07 , 0x7f , 0xbf , 0xdf , 0xef , 0xf7 , 0xfb , 0xfd , 0xfe};
char led[]={0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void delay(int xms) {
int i,j;
for(i=1;i<=xms;i++)
for(j=1;j<=112;j++);
}
main(){
while(1){
P0=smg[1]; //显示数字1
du=1;
du=0;
P0=smg[8];
we=1;
we=0;
P1=led[1];
fm=0;
delay(500);
fm=1;
delay(500);
P0=smg[2]; //显示数字2
du=1;
du=0;
P0=smg[9];
we=1;
we=0;
P1=led[2];
fm=0;
delay(500);
fm=1;
delay(500);
fm=0;
delay(500);
fm=1;
delay(500);
P0=smg[3]; //显示数字3
du=1;
du=0;
P0=smg[10];
we=1;
we=0;
P1=led[3];
fm=0;
delay(500);
fm=1;
delay(500);
P0=smg[4]; //显示数字4
du=1;
du=0;
P0=smg[11];
we=1;
we=0;
P1=led[4];
fm=0;
delay(500);
fm=1;
delay(500);
fm=0;
delay(500);
fm=1;
delay(500);
P0=smg[5]; //显示数字5
du=1;
du=0;
P0=smg[12];
we=1;
we=0;
P1=led[5];
fm=0;
delay(500);
fm=1;
delay(500);
P0=smg[6]; //显示数字6
du=1;
du=0;
P0=smg[13];
we=1;
we=0;
P1=led[6];
fm=0;
delay(500);
fm=1;
delay(500);
fm=0;
delay(500);
fm=1;
delay(500);
P0=smg[7]; //显示数字7
du=1;
du=0;
P0=smg[14];
we=1;
we=0;
P1=led[7];
fm=0;
delay(500);
fm=1;
delay(500);
P0=smg[8]; //显示数字8
du=1;
du=0;
P0=smg[15];
we=1;
we=0;
P1=led[8];
fm=0;
delay(500);
fm=1;
delay(500);
fm=0;
delay(500);
fm=1;
delay(500);
}
}