#include <REGX51.H>
sbit key1 = P3^1;
sbit key2 = P3^2;
sbit led1 = P3^3;
sbit led2 = P3^4;
unsigned char seg[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
signed char num = 9;
void delay (unsigned int x)
{
while(x--);
}
void display ()
{
P1 = seg[num]; led1 = 0;led2 = 1;
if (key1==0)
{
num++;
delay (300);
led1 =! led1;
led2 =! led2;
if (num>9)
{
num = 0;
} while (key1==0);
}
if(key2==0)
{
num--;
delay (300);
led1 =! led1;
led2 =! led2;
if (num<0)
{
num = 9;
} while (key2==0);
}
}
void main() { while(1) { display (); }
}