P3=0xf0;
scan1=P3;
if(scan1!=0xf0)
{ delay(8);
if(scan1!=0xf0)
{ P3=0x0f;
scan2=P3;
keycode=(scan1|scan2);
switch(keycode)
{ case 0xee: zhengrunflag=1;shuzi=0;break;
case 0xde: fanrunflag=1;shuzi=0;break;
case 0xbe: stopflag=1;shuzi=0;break;
case 0xed: zhuansushezhiflag=1;shuzi=0;break;
case 0xdd: jiaodushezhiflag=1;shuzi=0;break;
case 0xbd: chuzhi=0;shuzi=1;break;
case 0x7d: chuzhi=1;shuzi=1;break;
case 0xeb: chuzhi=2; shuzi=1;break;
case 0xdb: chuzhi=3;shuzi=1;break;
case 0xbb: chuzhi=4;shuzi=1;break;
case 0x7b: chuzhi=5;shuzi=1;break;
case 0xe7: chuzhi=6;shuzi=1;break;
case 0xd7: chuzhi=7;shuzi=1;break;
case 0xb7: chuzhi=8;shuzi=1;break;
case 0x77: chuzhi=9;shuzi=1;break;
}
}
else shuzi=0;
P3=0xf0;
scan1=P3;
if(scan1!=0xf0)
{ delay(8);
if(scan1!=0xf0)
{ P3=0x0f;
scan2=P3;
keycode=(scan1|scan2);
switch(keycode)
{ case 0xee: zhengrunflag=1;shuzi=0;break;
case 0xde: fanrunflag=1;shuzi=0;break;
case 0xbe: stopflag=1;shuzi=0;break;
case 0xed: zhuansushezhiflag=1;shuzi=0;break;
case 0xdd: jiaodushezhiflag=1;shuzi=0;break;
case 0xbd: chuzhi=0;shuzi=1;break;
case 0x7d: chuzhi=1;shuzi=1;break;
case 0xeb: chuzhi=2; shuzi=1;break;
case 0xdb: chuzhi=3;shuzi=1;break;
case 0xbb: chuzhi=4;shuzi=1;break;
case 0x7b: chuzhi=5;shuzi=1;break;
case 0xe7: chuzhi=6;shuzi=1;break;
case 0xd7: chuzhi=7;shuzi=1;break;
case 0xb7: chuzhi=8;shuzi=1;break;
case 0x77: chuzhi=9;shuzi=1;break;
}
}
else shuzi=0;