#include<at89x52.h>
#define uchar unsigned char
sbit k1=P3^0;
sbit k2=P3^2;
uchar code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void delay1ms(uchar a)
{
uchar b,c;
for(c=1;c>0;c--)
for(b=142;b>0;b--)
for(a=2;a>0;a--);
}
void main()
{
uchar i;
while(1)
{
if(!k1)
{
delay1ms(10);
if(!k1)
{
P2=tab[i++];
}
while(!k1);
}
if(!k2)
{
delay1ms(10);
if(!k2)
{
P2=tab[i--];
}
while(!k2);
}
}
}
|