//此按键数为3*8, 可支持8*8
#include<reg51.h>
#define COM(x1,x2,x3,x4,x5,x6,x7,x8) ((x1&0xff)|((x2&0xff)<<1)|((x3&0xff)<<2)|((x4&0xff)<<3)|((x5&0xff)<<4)|((x6&0xff)<<5)|((x7&0xff)<<6)|((x8&0xff)<<7)) //编成一个字节数据
#define ROW_NUM 3 //矩阵列数
sbit Gate1 = P3^2; //按键控制端口1(列扫描)共8*3列
sbit Gate2 = P3^3; //按键控制端口2(列扫描)
sbit Gate3 = P3^4; //按键控制端口3(列扫描)
sbit Dial_KeyOne = P0^6;//表盘按键1 矩阵不管怎样接,只改变这里的定义
sbit Dial_KeyTwo = P2^6;//表盘按键2
sbit Dial_KeyThree = P2^7;//表盘按键3
sbit Dial_KeyFour = P2^5;//表盘按键4
sbit Dial_KeyFine = P2^4;//表盘按键5
sbit Dial_KeySix = P2^3;//表盘按键6
sbit Dial_KeySeven = P2^0;//表盘按键7
sbit Dial_KeyEight = P3^0;//表盘按键8
/
//矩阵按键扫描,有按键按下,返回
//相应按键编码,