/*
程序效果:按下按键,蜂鸣器响,数码管有相应的键值
显示,按下E键继电器关,按下C键继电器开。
这与上一程序的功能相同,比上一程序简洁
但理解相对困难些。
运行平台:51hei单片机学习板
*/
#include //头文件
#include
#define uchar unsigned char //宏定义
#define uint unsigned int
sbit jdq=P3^5; //位声明,驱动继电器管脚
sbit fmq=P3^4; //位声明,驱动蜂鸣器管脚
code uchar table[]={0x3f,0x06,0x5b,//数码管显示的数值
0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,
0x77,0x7c,0x39,0x5e,0x79,0x71};
code uchar key_tab[17]={ //此数组为键盘编码
0xed,0x7e,0x7d,0x7b, // 0,1,2,3,
0xbe,0xbd,0xbb,0xde, // 4,5,6,7,
0xdd,0xdb,0x77,0xb7, // 8,9,a, b,
0xee,0xeb,0xd7,0xe7,0xff}; // c,d,e,f,
uchar l_key=0x00; //定义变量,存放键值