|
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
矩陣式鍵盤(pán).png (70.74 KB, 下載次數(shù): 46)
下載附件
2021-11-25 19:53 上傳
無(wú)標(biāo)題.png (37.57 KB, 下載次數(shù): 46)
下載附件
2021-11-25 19:53 上傳
單片機(jī)源程序如下:
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x00};//0-f-最后一個(gè)空
uchar j=1;
sbit p37=P3^7;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar shu)
{
P1=table[shu];
delay(5);
}
uchar keyscan()
{
uchar temp,num;
P2=0xfe;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case 0xee:num=1;break;
case 0xde:num=2;break;
case 0xbe:num=3;break;
default:break;
}
while(temp!=0xf0)//**********松手檢測(cè) 松手后顯示
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
P2=0xfd;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case 0xed:num=4;break;
case 0xdd:num=5;break;
case 0xbd:num=6;break;
}
while(temp!=0xf0)
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
P2=0xfb;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case 0xeb:num=7;break;
case 0xdb:num=8;break;
case 0xbb:num=9;break;
}
while(temp!=0xf0)
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
P2=0xf7;
temp=P2;
temp=temp&0xf0;
if(temp!=0xf0)
{
p37=0;
delay(5);
temp=P2;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P2;
switch(temp)
{
case 0xe7:num=16;break;
case 0xd7:num=0;break;
case 0xb7:num=16;break;
}
while(temp!=0xf0)
{
j=0;
temp=P2;
temp=temp&0xf0;
}
}
}p37=1;
//if(j==1)num=16;
return num;
}
void main()
{
p37=1;
while(1)
{
display(keyscan());
//display(7);
}
}
仿真.7z
(117.53 KB, 下載次數(shù): 72)
2021-11-25 19:53 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
視頻.7z
(6.02 MB, 下載次數(shù): 14)
2021-11-25 19:55 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|