金波开发板矩阵键盘的扫描程序
#include<reg52.h>
#include<intrins.h>
#include<absacc.h>
//键盘扫描程序及其他控制的程序
//请将开发板的j7、j8、j10的跳线短接
unsigned char bdata data_574;
sbit keyout0 = data_574^0;
sbit keyout1 = data_574^1;
sbit keyout2 = data_574^2;
sbit keyout3 = data_574^3;
sbit keyout4 = data_574^4;
sbit keyout5 = data_574^5;
sbit buzzer_ = data_574^6;
sbit relay_ = data_574^7;
#define out_port
XBYTE[0x8400]
//574锁存器输出地址
#define in_port
XBYTE[0x8300]
//245输入地址
unsigned char key;
void delay();
unsigned char get_key();
void main()
{
unsigned
char temp;
data_574
= 0xff;
out_port =
data_574;
while(1)
{
delay();
temp = get_key();
if((temp != 0) && (temp !=
key))
{
//当值不为零,且与上一键值不相等,说明有新键值产生
out_port = data_574;
switch(temp)
{
case 1:
relay_ =
0;
//继电器吸合
break;
case 2:
relay_ =
1;
//继电器关闭
break;
case 3:
P1 =
0x00;
//led开
break;
case 4:
P1 =
0xff;
//led关
break;
case 5:
buzzer_ =
0;
//蜂鸣器响