第2个回答 2018-05-16
#include<reg51.h>
sbit k1=P1^0;
#define uint16 unsigned int
#define uchar unsigned char
uchar code shuzu[ ]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay()
{
uint16 i=1000;
while(i--);
}
void main()
{
uchar n ;
P2=0xfe;
P1=0xff;
while(1)
{
if(k1==0)
{
if(n>=9) n=0;
else n++;
P0=shuzu[n];
while(!k1);
delay();
while(!k1);
}
}
}