#i nclude<reg52.h>#define uint unsigned int#define uchar unsigned char#define duank P1 //键盘到单片机的端口//DB 50H,1CH,39H,16H,38H,78H,70H,0FEH,0EFH,0FFH;A B, C, D, E, ,F ,P, -, ,. ,COLSE//DB 01H,0C7H,22H,82H,0C4H,88H,08H,0C3H,00H,80H;带小数点的字形码0.,1.,-----9.uchar code table[]={ //键盘编码"1~F~0"0xD7,0x32,0x92,0xD4,0x98,0x18,0xD1,0x10,0x90,0x50,0x1C,0x39,0x16,0x38,0x78,0x11};uchar num,temp,num1;void delay(uint z) //延时子程序 Zms { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--);}uchar keyscan(); //键盘函数声明void display(uchar aa);//显示函数声明void main() //主函数{ while(1) { display(keyscan()); }}void display(uchar aa) //显示子程序{ //dula=1; //P0=table[aa-1]; //dula=0; SBUF=table[aa-1];}uchar keyscan() //键盘扫描程序,取回一个键盘号{ duank=0xfe; temp=duank; temp=temp&0xf0; while(temp!=0xf0) { delay(5); temp=duank; temp=temp&0xf0; while(temp!=0xf0) { temp=duank; switch(temp) { case 0xee:num=1; break; |