<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 51單片機程序——4乘4矩陣鍵盤(pán)使用方法

51單片機程序——4乘4矩陣鍵盤(pán)使用方法

作者: 時(shí)間:2016-11-23 來(lái)源:網(wǎng)絡(luò ) 收藏
#include
#define uint unsigned int
#define uchar unsigned char
#define dula P0
#define wela P1
unsigned char code DuanMa[]={0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xa7,0xa1,0x86,0x8e,0xff};
uchar num,temp;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
uchar keyscan();
void display(uchar aa);
void main()
{
num=16;
while(1)
{
display(keyscan());
}
}
void display(uchar aa)
{
wela=0xff;
dula=DuanMa[aa];
}
uchar keyscan()
{
P2=0xef;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f) //確認是否按下
{
delay(5);
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
switch(temp)
{
case 0xee:num=0;
break;
case 0xed:num=1;
break;
case 0xeb:num=2;
break;
case 0xe7:num=3;
break;
}
while(temp!=0x0f) //松手檢測
{
temp=P2;
temp=temp&0x0f;
}
}
}
P2=0xdf;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
delay(5);
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
switch(temp)
{
case 0xde:num=4;
break;
case 0xdd:num=5;
break;
case 0xdb:num=6;
break;
case 0xd7:num=7;
break;
}
while(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
}
}
}
P2=0xbf;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
delay(5);
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
switch(temp)
{
case 0xbe:num=8;
break;
case 0xbd:num=9;
break;
case 0xbb:num=10;
break;
case 0xb7:num=11;
break;
}
while(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
}
}
}
P2=0x7f;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
delay(5);
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
switch(temp)
{
case 0x7e:num=12;
break;
case 0x7d:num=13;
break;
case 0x7b:num=14;
break;
case 0x77:num=15;
break;
}
while(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
}
}
}
return num;
}



關(guān)鍵詞: 51單片機4乘4矩陣鍵

評論


技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>