#include "reg52.h"
//#include "scancodes.h"
#include "lcd1602.h"
#define uchar unsigned char
#define uint unsigned int
#define out P2
#define chu P3
uchar DisNum;
void delay(unsigned int k);
uchar keyscan(void);
unsigned char code key[16][2] = {
0x7e, '0',
0x7d, '1',
0x7b, '2',
0x77, '3',
0xbe, '4',
0xbd, '5',
0xbb, '6',
0xb7, '7',
0xde, '8',
0xdd, '9',
0xdb, 'a',
0xd7, 'b',
0xee, 'c',
0xed, 'd',
0xeb, 'e',
0xe7, 'f',
};
void main ()
{ int i=0;
uchar key;
while(1)
{
key=keyscan();
for (i=1;(key[0]!=key)&&(i<16);i++);//查表显示
if (key[0]==key)
{
ShowChar(DisNum,key[1]);
DisNum++;
if(DisNum==32)
{
WriteCommand(0x01);//清屏
DisNum=0;//重头写数据
}
}
}
}
/*------------------------------------------------
键盘扫描程序
------------------------------------------------*/
uchar keyscan(void) //键盘扫描函数,使用行列反转扫描法
{
uchar cord_h,cord_l;//行列值中间变量
P3=0x0f; //行线输出全为0
cord_h=P3&0x0f; //读入列线值
if(cord_h!=0x0f) //先检测有无按键按下
{
delay(100); //去抖
if(cord_h!=0x0f)
{
cord_h=P3&0x0f; //读入列线值
P3=cord_h|0xf0; //输出当前列线值
cord_l=P3&0xf0; //读入行线值
return(cord_h+cord_l);//键盘最后组合码值
}
}return(0xff); //返回该值
}
/*------------------------------------------------
延时程序
------------------------------------------------*/
void delay(unsigned int k)
{
unsigned j,i;
for(i=0;i<k;i++)
{
for(j=0;j<100;j++);
}
}
红色那行有这个问题,不知道咋回事?????……
TEXT1.C(35): error C216: subscript on non-array or too many dimensions
红色那行有这个问题,不知道咋回事?????…… |