51单片机矩阵键盘特征码法法
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
temp =P0;
if (temp!=0xf0)//消抖程序
{ P0 =0xf0;
temp =P0;
P0 =0x0f;
temp1 =P0;
temp =temp|temp1;
switch (temp)
{case 0xed: keyzhi=0;break;
case 0xdd: keyzhi=1;break;
#include <reg51.h>
#include <intrins.h>
unsigned char code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x40,};
unsigned char temp;
}
}
}
/******************按键显示程序****************/
void dis_play ()
{display = tab[keyzhi];
P1 =display;
P2 =0Xe7;
}
/*********************主函数**********************/
unsignedБайду номын сангаасchar display;
unsigned char keyzhi=12;
unsigned char temp1=0;
/****************延时函数********************/
void deley(unsigned int xms) //
{unsigned char i,j;//
for(i=xms;i>0;i--)//
for (j=115;j>0;j--);//
}
/***************按键检测函数**********************/
void key()
{ P0 =0xff;
P0 =0Xf0;
temp =P0;
if (temp!=0xf0)
{deley (10);
case 0xe7: keyzhi=8;break;
case 0xd7: keyzhi=9;break;
case 0xb7: keyzhi=10;break;
case 0x77: keyzhi=11;break;}
P0 =0Xf0;
temp =P0;
while (temp!=0xf0)
{temp =P0;}
case 0xbd: keyzhi=2;break;
case 0x7d: keyzhi=3;break;
case 0xeb: keyzhi=4;break;
case 0xdb: keyzhi=5;break;
case 0xbb: keyzhi=6;break;
case 0x7b: keyzhi=7;break;
void main ()
{ while (1)
{key ();
dis_play();
}
}
if (temp!=0xf0)//消抖程序
{ P0 =0xf0;
temp =P0;
P0 =0x0f;
temp1 =P0;
temp =temp|temp1;
switch (temp)
{case 0xed: keyzhi=0;break;
case 0xdd: keyzhi=1;break;
#include <reg51.h>
#include <intrins.h>
unsigned char code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x40,};
unsigned char temp;
}
}
}
/******************按键显示程序****************/
void dis_play ()
{display = tab[keyzhi];
P1 =display;
P2 =0Xe7;
}
/*********************主函数**********************/
unsignedБайду номын сангаасchar display;
unsigned char keyzhi=12;
unsigned char temp1=0;
/****************延时函数********************/
void deley(unsigned int xms) //
{unsigned char i,j;//
for(i=xms;i>0;i--)//
for (j=115;j>0;j--);//
}
/***************按键检测函数**********************/
void key()
{ P0 =0xff;
P0 =0Xf0;
temp =P0;
if (temp!=0xf0)
{deley (10);
case 0xe7: keyzhi=8;break;
case 0xd7: keyzhi=9;break;
case 0xb7: keyzhi=10;break;
case 0x77: keyzhi=11;break;}
P0 =0Xf0;
temp =P0;
while (temp!=0xf0)
{temp =P0;}
case 0xbd: keyzhi=2;break;
case 0x7d: keyzhi=3;break;
case 0xeb: keyzhi=4;break;
case 0xdb: keyzhi=5;break;
case 0xbb: keyzhi=6;break;
case 0x7b: keyzhi=7;break;
void main ()
{ while (1)
{key ();
dis_play();
}
}