这是源程序:
#include "reg52.h"
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66};
unsigned char keyscan()
{unsigned char keyv,temp;
keyv=0;
P2=0xff;
temp=P2;
if(~(P2&temp))
{switch(temp)
{case 0xfe:
keyv=1;break;
case 0xfd:
keyv=2;break;
case 0xfb:
keyv=3;break;
case 0xf7:
keyv=4;break;
default:
keyv=0;break;
}
}
return keyv;
}
void main ()
{
unsigned char ledshow;
while(1)
{ledshow=keyscan();
P1=table[ledshow];
}
}
本人初学者,希望各位指点下,在线等待中......
-
这是仿真电路图
一周热门 更多>