![37f41ee46f52ef3d5dda8cdf775e17f0.png](https://i-blog.csdnimg.cn/blog_migrate/734e7943e9aeca5deb0c44d5ea7cca69.jpeg)
开机显示0,按键2,数码管加1显示, 按键3,数码管减1显示。
![4ccf4d0abbbf633f022835d21120dd6b.png](https://i-blog.csdnimg.cn/blog_migrate/baa1caaee182a3816167927cf21dbe7d.jpeg)
#include
code unsigned char sz []={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
void delay();
sbit P10=P1^0;
sbit sw0=P3^5;
sbit sw1=P3^6;
void main ()
{
char mun=0;
P10=0;
P0=sz[0];
while(1)
{
if (sw0==0)
{
delay();
if (sw0==0)
{
do
{
while (sw0==0);
delay();
}
while (sw0==0);
mun--;
if (mun<0) mun=0x09;
P0=sz [mun];
}
}
if (sw1==0)
{
delay();
if(sw1==0)
{
do
{
while(sw1==0);
delay();
}
while (sw1==0);
mun++;
if (mun>0x09) mun=0;
P0=sz [mun];
}
}
}
}
void delay()
{
unsigned int i;
i=10000;
while(i--);
}