#include <reg52.h>
code unsigned char seg7code[10]={ 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char a=1;
unsigned char Z;
sbit P2_4=P2^4;//显示数字
void del()
{
unsigned char i,j,k;
for(i=20;i>0;i--)
for(j=20;j>0;j--)
for(k=248;k>0;k--);
}
main()
{
P1=0xff;
P2_4=0;
Z=P1;
P0=seg7code[0];
switch ( Z ) //判断键值(那一个键按下)
{
case 0xfe:P0=seg7code[1]; goto LP;
case 0xfd:P0=seg7code[2]; goto LP;
case 0xfb:P0=seg7code[3]; goto LP;
case 0xf7:P0=seg7code[4]; goto LP;
case 0xef:P0=seg7code[5]; goto LP;
case 0xdf:P0=seg7code[6]; goto LP;
case 0xbf:P0=seg7code[7]; goto LP;
case 0x7f:P0=seg7code[8]; goto LP;
while(1)
{
LP:
P3=0xf0;
del();
P3=0x0f;
del();
}
}
}