您的当前位置:首页正文

4x4矩阵键盘电路连接图和快速扫描完整程序

2023-06-16 来源:尚车旅游网


4*4矩阵键盘电路连接图和快速扫描完整程序

RP1非编码键盘扫描C1U130pF19XTAL1P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RDRESPACK-81X1CRYSTAL18C230pFXTAL29RST393837363534333221222324252627281011121314151617LE1LE2293031PSENALEEAP1.7P1.0P1.1P1.2P1.3P1.6P1.5P1.412345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51U2D0D1D2D3D4D5D6D723456789D0D1D2D3D4D5D6D7LEOE74HC573Q0Q1Q2Q3Q4Q5Q6Q71918171615141312LE1111U3D0D1D2D3D4D5D6D723456789D0D1D2D3D4D5D6D7LEOE74HC573Q0Q1Q2Q3Q4Q5Q6Q71918171615141312D0D1D2D3D4D5D6D723456789Created By 晓竹2013-07-19LE2111 #include

#include

#define uint unsigned int

#define uchar unsigned char

uchar code

wei[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xb9,0xbf,0x89,0xad,0x7f,0xff};

uchar temp=0xfe; //键盘扫描前赋给P1口的试探值

uchar beis=0x00; //键盘扫描的识别倍率

sbit LE1=P2^0;

sbit LE2=P2^1;

uchar key,sm;//key是扫描得到的键值;

////////////////////////////////////////////////////////////////////

//显示函数,静态显示

void xianshi(uchar x)

{

uint b=200;

LE2=1;

P0=0X0F;

LE2=0;

LE1=1;

P0=wei[x];

while(b--);

LE1=0;

}

////////////////////////////////////////////////////////////////////

//4*4矩阵扫描,键值保存在key中

void key_4x4()

{

P1=temp; //初值uchar temp=0xfe;

sm=P1;

sm=sm&0xf0; //取P1口高四位的值,如果为0就表示无键按下

if(sm!=0xf0)

{

switch(sm)

{

case 0x70:{key=0+4*beis;break;}

case 0xb0:{key=1+4*beis;break;}

case 0xd0:{key=2+4*beis;break;}

case 0xe0:{key=3+4*beis;break;}

default :{key=10+4*beis;break;}

}

}

else

{

if(temp==0xf7)

{

temp=0xfe;

}

else

{

temp=_crol_(temp,1);

}

beis++;

if(beis==4)beis=0;

}

}

////////////////////////////////////////////////////////////////////

//主函数

void main()

{

while(1)

{

key_4x4();

xianshi(key);

}

}

因篇幅问题不能全部显示,请点此查看更多更全内容