单片机矩阵键盘行列扫描程序
摘要://行列扫描程序,可以自己定义端口和扫描方式,这里做简单介绍#include<>//包含头文件#defineucharunsignedchar#defineuintunsignedintunsignedchardofly[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//0-Fucharkeyscan(void);voiddelay(uinti);voidmain(){ucharkey;P2=0x00;//1数码管亮按相应的按键,会显示按键上的字符while(1){key=keyscan();//调用键盘扫描,switch(key){case0x7e:P0=dofly[0];break;//0按下相应的键显示相对应的码值case0x7d:P0=dofly[1];break;//1case0x7b:P0=dofly[2];break;//2case0x77:P0=dofly[3];break;//3case0xbe:P0=dofly[4];break;//4case0xbd:P0=dofly[5];break;//5case0xbb:P0=dofly[6];break;//6case0xb7:P0=dofly[7];break;//7case0xde:P0=dofly[8];break;//8case0xdd:P0=dofly[9];break;//9case0xdb:P0=dofly[10];break;//acase0xd7:P0=
温馨提示:当前文档最多只能预览
5 页,若文档总页数超出了
5 页,请下载原文档以浏览全部内容。
本文档由 匿名用户 于 2020-11-11 08:51:32上传分享