#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char const EL[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00};
uchar keyscan(void);
void delay(uint i);
void main()
{
uchar key;
P2=0;
P1=0X00;
while(1)
{
key=keyscan();
switch(key)
{
case 0xee:P1=EL[0];break;
case 0xed:P1=EL[1];break;
case 0xeb:P1=EL[2];break;
case 0xe7:P1=EL[3];break;
case 0xde:P1=EL[4];break;
case 0xdd:P1=EL[5];break;
case 0xdb:P1=EL[6];break;
case 0xd7:P1=EL[7];break;
case 0xbe:P1=EL[8];break;
case 0xbd:P1=EL[9];break;
case 0xbb:P1=EL[10];break;
case 0xb7:P1=EL[11];break;
case 0x7e:P1=EL[12];break;
case 0x7d:P1=EL[13];break;
case 0x7b:P1=EL[14];break;
case 0x77:P1=EL[15];break;
}
}
}
uchar keyscan(void)
{
uchar cord_h,cord_l;
P1=0x0f;
cord_l=P1&0x0f;
if(cord_l!=0x0f)
{
delay(100);
if(cord_l!=0x0f)
{
cord_l=P1&0x0f;
P1=cord_l|0xf0;
cord_h=P1&0xf0;
return(cord_l+cord_h);
}
}
return(0xff);
}
void delay(uint i)
{
while(i--);
}
网上找的程序,用不起,求高手指点
一周热门 更多>