⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 +

📁 键盘接口与编程.包含1.矩阵式键盘的结构与工作原理.2.矩阵式键盘的按键识别方法 及源程序.
💻
📖 第 1 页 / 共 3 页
字号:
lang=EN-US>2.<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><![endif]><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">矩阵式键盘的按键识别方法</SPAN></P>
<P><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">确定矩阵式键盘上何键被按下介绍一种</SPAN><SPAN 
lang=EN-US>“</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">行扫描法</SPAN><SPAN 
lang=EN-US>”</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN></P>
<P><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">行扫描法</SPAN> 
<SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">行扫描法又称为逐行(或列)扫描查询法,是一种最常用的按键识别方法,如上图所示键盘,介绍过程如下。</SPAN></P>
<P 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo6; tab-stops: list 36.0pt"><![if !supportLists]><SPAN 
lang=EN-US>1.<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><![endif]><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断键盘中有无键按下</SPAN> 
<SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将全部行线</SPAN><SPAN 
lang=EN-US>Y0-Y3</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">置低电平,然后检测列线的状态。只要有一列的电平为低,则表示键盘中有键被按下,而且闭合的键位于低电平线与</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">根行线相交叉的</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个按键之中。若所有列线均为高电平,则键盘中无键按下。</SPAN></P>
<P 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo6; tab-stops: list 36.0pt"><![if !supportLists]><SPAN 
lang=EN-US>2.<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><![endif]><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">判断闭合键所在的位置</SPAN> 
<SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在确认有键按下后,即可进入确定具体闭合键的过程。其方法是:依次将行线置为低电平,即在置某根行线为低电平时,其它线为高电平。在确定某根行线位置为低电平后,再逐行检测各列线的电平状态。若某列为低,则该列线与置为低电平的行线交叉处的按键就是闭合的按键。</SPAN></P>
<P style="MARGIN-LEFT: 36pt"><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下面给出一个具体的例子:</SPAN></P>
<P><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图仍如上所示。</SPAN><SPAN 
lang=EN-US>8031</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">单片机的</SPAN><SPAN 
lang=EN-US>P1</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">口用作键盘</SPAN><SPAN 
lang=EN-US>I/O</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">口,键盘的列线接到</SPAN><SPAN 
lang=EN-US>P1</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">口的低</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">位,键盘的行线接到</SPAN><SPAN 
lang=EN-US>P1</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">口的高</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">位。列线</SPAN><SPAN 
lang=EN-US>P1.0-P1.3</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分别接有</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个上拉电阻到正电源</SPAN><SPAN 
lang=EN-US>+5V</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,并把列线</SPAN><SPAN 
lang=EN-US>P1.0-P1.3</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置为输入线,行线</SPAN><SPAN 
lang=EN-US>P1.4-P.17</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置为输出线。</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">根行线和</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">根列线形成</SPAN><SPAN 
lang=EN-US>16</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个相交点。</SPAN></P>
<P 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt"><![if !supportLists]><SPAN 
lang=EN-US>1.<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><![endif]><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">检测当前是否有键被按下。检测的方法是</SPAN><SPAN 
lang=EN-US>P1.4-P1.7</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">输出全</SPAN><SPAN 
lang=EN-US>“0”</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,读取</SPAN><SPAN 
lang=EN-US>P1.0-P1.3</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的状态,若</SPAN><SPAN 
lang=EN-US>P1.0-P1.3</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为全</SPAN><SPAN 
lang=EN-US>“1”</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,则无键闭合,否则有键闭合。</SPAN></P>
<P 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt"><![if !supportLists]><SPAN 
lang=EN-US>2.<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><![endif]><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">去除键抖动。当检测到有键按下后,延时一段时间再做下一步的检测判断。</SPAN></P>
<P 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt"><![if !supportLists]><SPAN 
lang=EN-US>3.<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><![endif]><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">若有键被按下,应识别出是哪一个键闭合。方法是对键盘的行线进行扫描。</SPAN><SPAN 
lang=EN-US>P1.4-P1.7</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">按下述</SPAN><SPAN 
lang=EN-US>4</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">种组合依次输出:</SPAN></P>
<P style="MARGIN-LEFT: 36pt"><SPAN lang=EN-US>P1.7 1 1 1 0</SPAN></P>
<P style="MARGIN-LEFT: 36pt"><SPAN lang=EN-US>P1.6 1 1 0 1</SPAN></P>
<P style="MARGIN-LEFT: 36pt"><SPAN lang=EN-US>P1.5 1 0 1 1</SPAN></P>
<P style="MARGIN-LEFT: 36pt"><SPAN lang=EN-US>P1.4 0 1 1 1</SPAN></P>
<P style="MARGIN-LEFT: 36pt"><SPAN lang=EN-US><SPAN 
style="mso-tab-count: 1">&nbsp; </SPAN></SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在每组行输出时读取</SPAN><SPAN 
lang=EN-US>P1.0-P1.3</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,若全为</SPAN><SPAN 
lang=EN-US>“1”</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,则表示为</SPAN><SPAN 
lang=EN-US>“0”</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这一行没有键闭合,否则有键闭合。由此得到闭合键的行值和列值,然后可采用计算法或查表法将闭合键的行值和列值转换成所定义的键值</SPAN></P>
<P 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-list: l3 level1 lfo8; tab-stops: list 36.0pt"><![if !supportLists]><SPAN 
lang=EN-US>4.<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><![endif]><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为了保证键每闭合一次</SPAN><SPAN 
lang=EN-US>CPU</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">仅作一次处理,必须却除键释放时的抖动。</SPAN></P>
<TABLE 
style="MARGIN-LEFT: 36pt; WIDTH: 225pt; mso-cellspacing: 1.5pt; mso-padding-alt: 1.5pt 1.5pt 1.5pt 1.5pt" 
cellPadding=0 width=300 border=0>
  <TBODY>
  <TR style="HEIGHT: 246pt">
    <TD 
    style="PADDING-RIGHT: 1.5pt; PADDING-LEFT: 1.5pt; PADDING-BOTTOM: 1.5pt; PADDING-TOP: 1.5pt; HEIGHT: 246pt">
      <P class=MsoNormal><SPAN lang=EN-US><IMG id=_x0000_i1026 height=324 
      src="键盘接口与编程.files/DPJ282.gif" width=362 align=bottom></SPAN><SPAN 
      lang=EN-US 
    style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体"><o:p></o:p></SPAN></P></TD></TR>
  <TR>
    <TD 
    style="PADDING-RIGHT: 1.5pt; PADDING-LEFT: 1.5pt; PADDING-BOTTOM: 1.5pt; PADDING-TOP: 1.5pt">
      <P class=MsoNormal><SPAN lang=EN-US><IMG id=_x0000_i1027 height=296 
      src="键盘接口与编程.files/DPJ283.gif" width=362></SPAN><SPAN lang=EN-US 
      style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体"><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
<P><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">键盘扫描程序:</SPAN></P>
<P><SPAN lang=EN-US><SPAN 
style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN><SPAN 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -