#include<reg51.h>
unsigned char code table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0xff,0x00,0xff,0x00};
unsigned char code table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x3f};
sbit kg=P3^0;
void Delay()
{
unsigned char i,j,k;
for(i=0;i<20;i++)
for(j=0;j<20;j++)
for(k=0;k<248;k++);
}
void main(void)
{
unsigned char i,j;
LED: for(j=0;j<36;j++)
{
P0=0x00;
if(kg==0) goto EG;
P1=table[j];
Delay();
}
EG: for(i=0;i<10;i++)
{
P1=0xff;
if(kg==1) goto LED;
P0=table1
;
Delay();
}
}
我调试过了,你试试