|
因为是在虚拟机用的仿真软件,所以在我本机不显示仿真软件的标识。
- #include <reg52.h>
- void delay(unsigned int ms)
- {
- unsigned char t;
- while(ms--)
- for(t=0;t<=120;t++);
- }
- unsigned char keyscan()
- {
- unsigned char row,col,k=0xff;
- unsigned char i;
- //unsigned char code keycode[]= {0xee,0xde,0xbe,0x7e,
- //0xed,0xdd,0xbd,0x7d,
- //0xeb,0xdb,0xbb,0x7b,
- //0xe7,0xd7,0xb7,0x77};
- unsigned char code keycode[]= {0xee,0xde,0xbe,0x7e,
- 0xed,0xdd,0xbd,0x7d,
- 0xeb,0xdb,0xbb,0x7b,
- 0xe7,0xd7,0xb7,0x77};
-
- P2=0xf0;
- if((P2&0xf0)==0xf0)
- return k;
- delay(20);
- if((P2&0xf0)==0xf0)
- return k;
- P2=0xf0;
- col=P2&0xf0;
- P2=col|0x0f;
- row=P2&0x0f;
- for(i=0;i<16;i++)
- if((row|col)==keycode[i])
- { k=i;
- break;
- }
- P2=0xf0;
- while((P2&0xf0)!=0xf0);
- return k;
- }
复制代码
|
|