51单片机的键盘扫描程序,算法简单有效

51单片机的键盘扫描程序,算法简单有效

ID:31701039

大小:75.25 KB

页数:11页

时间:2019-01-17

51单片机的键盘扫描程序,算法简单有效_第1页
51单片机的键盘扫描程序,算法简单有效_第2页
51单片机的键盘扫描程序,算法简单有效_第3页
51单片机的键盘扫描程序,算法简单有效_第4页
51单片机的键盘扫描程序,算法简单有效_第5页
资源描述:

《51单片机的键盘扫描程序,算法简单有效》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、Senda51single-chipkeyboardscanningprogram,thealgorithmissimpleandeffective/slzsixsixsixsixsixsix/#

2、S#

3、SxpxXTXxpxxpxxpxxpxXTXxpxxpxxpxXTXXTXXTXXTXXTXXTXXTXXTXXTX✓JX彳UDonotusekeyboardtimerwithoutdelayCharacteristic:Thekeyiseffectiveafterloosening,thesensitivityishigh,theconsumption

4、isless,andtheoperationefficiencyishighTheindependentkeyboardis:K01=P24;K02=P25;K03=P26;K04二P2"7;Matrixkeyboard:line(toptobottom)P2.3P2.2P2.1P2.0Column(lefttoright)P2.7P2.6P2.5P2.4Suppliedoperatingfunctions://independentkeyboard・Nobuttonmovesthevalueitreturnsnumkey=0,otherwisether

5、eturnbuttonnumbernumkeyExtern,unsigned,char,keyboardself();//matrixkeyboard.Nobuttonmovesthereturnvalueofnumkey=0,otherwisethereturnbuttonnumbernumkey****detectionfourExtern,unsigned,char,keyboard_matrix();Lookattheindependentkeyboard(thesameasthematrixkeyboard)#include#

6、include//independentkeyboard・Nobuttonmovesthevalueitreturnsnum_key=0,otherwisethereturnbuttonnumbernum_keyExtern,unsigned,char,keyboard_self()Unsignedcharnum_key=0;//key.Unsignedchartemp二0;//P2keyvalueforreadingonlineStaticunsignedchartemp_code=0;//savekeyvalueStaticun

7、signedcharnum_check=0;//lowleveleffectivenumberStaticunsignedcharkey_flag=0//keyeffectiveidentificationTemp二P2&0xF0;readtheP2datalineIf(temp!二OxFO)/lowleveljudgmentNumcheck++;If(num_check=10)/10consecutive(10ms)activelow,believesthatthekeyiseffectiveKey_flag=l;//enableeffectiveid

8、entificationkeysTemp_code=temp;//savekeyvalueElse//judgewhenyouletgoNum_check=0;If(key_flag==l)/keyiseffectiveKey_flag=0;Switch(temp_code)//readthekeynumberCaseOxEO:num_key=l;Break;CaseOxDO:num_key=2;Break;CaseOxBO:num_key=3:Break;case0x70:num_key二4;break;return(num_key);现在是矩阵键盘的

9、#ineludereg52.h><#includeintrins.h>

10、cunsignedcharnum_check=0;//低电平计数thestati

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。