单片机显示1-9
#include <reg51.h>
#define uchar unsigned char
sbit key=P1^0;
uchar i,j;
xianshima[3]={0xc0,0xf9,0xa4};
void delay ( i )
{
while (i--);
}
void main()
{
j=0;
while(1)
{
if(key==0)
{
delay(1000);
P2=xianshima[j];
j=j+1;
while(key==0) ;
}
}
}

浙公网安备 33010602011771号