C51矩阵键盘扫描程序
2011-11-12 21:07
387 查看
#include <reg52.h> #include <intrins.h> #define uchar unsigned char sfr KeyPort=0x90; //#define KeyPort P1 -----行在P1口低四位 //sbit Key_C1=P1^4; //第1列接P1.4 //sbit Key_C2=P1^5; //第2列接P1.5 //sbit Key_C3=P1^6; //第3列接P1.6 sfr Led=0x80; //#define Led P0--------P0口LED void delay(uchar ms); void main() { uchar totle=0; Led=0xff; while(1) { KeyPort=0x6f; //0110 1111 if(KeyPort!=0x6f) { delay(10); if(KeyPort!=0x6f) { switch(KeyPort) { case 0x6e: //0110 1110 //Led=_crol_(Led,1); // Led=1; totle=totle+0x01; Led=totle; break; case 0x6d: //0110 1101 //Led=_crol_(Led,4); //Led=0x4; totle=totle+0x4; Led=totle; break; case 0x6b: //0110 1011 //Led=_crol_(Led,7); //Led=0x7; totle=+totle+0x7; Led=totle; break; case 0x67: //0110 0111 //Led=_crol_(Led,10); totle=0x00; Led=totle; break; } while(KeyPort!=0x6f); } } KeyPort=0x5f; //0101 1111 if(KeyPort!=0x5f) { delay(10); if(KeyPort!=0x5f) { switch(KeyPort) { case 0x5e: //0101 1110 //Led=_crol_(Led,2); //Led=0x2; totle=totle+0x2; Led=totle; break; case 0x5d: //0101 1101 //Led=_crol_(Led,5); //Led=0x5; totle=totle+0x5; Led=totle; break; case 0x5b: //0101 1011 //Led=_crol_(Led,8); //Led=0x8; totle=totle+0x8; Led=totle; break; case 0x57: //0101 0111 // Led=_crol_(Led,11); totle=totle+0x0; Led=totle; break; } while(KeyPort!=0x5f); } } KeyPort=0x3f; //0011 1111 if(KeyPort!=0x3f) { delay(10); if(KeyPort!=0x3f) { switch(KeyPort) { case 0x3e: //0011 1110 //Led=_crol_(Led,3); //Led=0x3; totle=totle+0x3; Led=totle; break; case 0x3d: //0011 1101 //Led=_crol_(Led,6); totle=totle+0x6; Led=totle; break; case 0x3b: //0011 1011 //Led=_crol_(Led,9); // Led=0x9; totle=totle+0x9; Led=totle; break; // case 0x37: //0011 0111 // Led=_crol_(Led,12); // break; } while(KeyPort!=0x3f); } } } } void delay(uchar ms) { uchar i; for(;ms>0;ms--) for(i=0;i<244;i++); }
相关文章推荐
- 数码管显示矩阵键盘扫描程序
- 51单片机的4x4矩阵键盘扫描例程(C51)
- C51行列键盘扫描程序
- 4X4矩阵键盘扫描程序
- linux下4x4矩阵 键盘驱动,用了定时器控制扫描程序来抗抖。
- 4X4矩阵键盘扫描程序
- 矩阵键盘扫描程序
- 4x4矩阵键盘 扫描程序
- 树莓派的矩阵键盘扫描程序,python开发
- AVR单片机(ATMEGA16)矩阵键盘扫描程序
- 矩阵键盘扫描程序实例
- 51单片机矩阵扫描键盘程序(源代码)
- 4X4矩阵键盘扫描程序
- 矩阵键盘终端扫描
- 键盘扫描程序
- VHDL 键盘扫描程序,用状态机实现
- 基于STM32L151//STM32F407的矩阵键盘程序(不规则接口):
- 键盘扫描程序进展顺利
- 自定义4*4矩阵键盘在Qt4程序中的使用方法
- Win10 IoT C#开发 6 - 4x4矩阵键盘扫描