欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
51單片機4X8鍵盤掃描電路圖+程序
[打印本頁]
作者:
daniu
時間:
2014-12-27 16:59
標題:
51單片機4X8鍵盤掃描電路圖+程序
//===============================================================
//程序編寫人:
//編寫地點:湖南源點IC培訓機構
//時間:2009年7月6日下午 星期一
//功能:本程序實現掃描4X8鍵盤,顯示鍵值0-31.
//===============================================================
#include <reg51.h>
#define uchar unsigned char
#define uint long unsigned int
#define ShuChu P1 //輸出口
#define PianXuan P0 //片選口
#define Jian1 P2 //行輸入口
#define Jian2 P3 //列輸入口
bit AnJian;
uchar n;
uint code tempt1[]={0x0efe,0x0dfe,0x0bfe,0x07fe,
0x0efd,0x0dfd,0x0bfd,0x07fd,
0x0efb,0x0dfb,0x0bfb,0x07fb,
0x0ef7,0x0df7,0x0bf7,0x07f7,
0x0eef,0x0def,0x0bef,0x07ef,
0x0edf,0x0ddf,0x0bdf,0x07df,
0x0ebf,0x0dbf,0x0bbf,0x07bf,
0x0e7f,0x0d7f,0x0b7f,0x077f};//反轉碼
uchar code tempt2[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};//共陽數碼管數據
void Delay(uchar M)//延時函數
{
uchar i,j;
for(j=M;j>0;j--)
for(i=125;i>0;i--);
}
void Display(uchar N)//顯示函數
{
ShuChu=tempt2[N/10]; //顯示十位
PianXuan=0x01;
Delay(20);
PianXuan=0x00;
ShuChu=tempt2[N%10]; //顯示個位
PianXuan=0x02;
Delay(20);
PianXuan=0x00;
}
uint SaoMiao(void)//掃描函數
{
uchar a,b;
uint d;
Jian1=0x00;
Jian2=0x0f;
a=Jian2&0x0f;
d=a<<8;
Jian1=0xff;
Jian2=0x00;
b=Jian1;
return (d=d|b); //返回讀取的鍵值
}
uchar DuJianZhi(uint K)//讀鍵值函數
{
uchar i=0,b;
if(K!=0x0fff)
{
AnJian=1;
while(K!=tempt1)
{
i++;
}
return b=i;
}
else
return b=n; //返回鍵值位置
}
main()//主函數
{
AnJian=0;
while(1)
{
P3=0x0f;
if(AnJian==1)
{
Display(n); //顯示鍵值
n=DuJianZhi(SaoMiao());
}
else
{
n=DuJianZhi(SaoMiao());
}
}
}
復制代碼
作者:
iming
時間:
2015-4-15 21:04
很好很強大。學習了。。。。
作者:
pengyongnet
時間:
2018-6-27 08:48
樓主分享下原理圖源文件和程序的源文件
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1