#include <reg51.h>
void delay(unsigned int i);
void main()
{
unsigned char button;
unsigned char code disp[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0xbf};
P0=0xff;
P1=disp[8];
while(1)
{
button=P0;
delay(1200);
button=P0;
switch(button)
{
case 0xfe: P1=disp[0];delay(10000);while(1);break;
case 0xfd: P1=disp[1];delay(10000);while(1);break;
case 0xfb: P1=disp[2];delay(10000);while(1);break;
case 0xf7: P1=disp[3];delay(10000);while(1);break;
case 0xef: P1=disp[4];delay(10000);while(1);break;
case 0xdf: P1=disp[5];delay(10000);while(1);break;
case 0xbf: P1=disp[6];delay(10000);while(1);break;
case 0x7f: P1=disp[7];delay(10000);while(1);break;
default: break;
}
}
}
void delay(unsigned int i)
{
unsigned int k;
for(k=0;k<i;k++);
}
|