#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,
0x6F,0x77,0x7C,0x39,0x5E,0x79};
uchar KEY0,KEY1 == 16;
uchar keyscan(void)
{
uchar Tmp;
P1 = 0xF0; //按健是接在P1口上
Tmp = P1;
switch (Tmp)
{
case 0xE0: KEY0 = 0; break; //第1行 按健判断
case 0xD0: KEY0 = 1; break; //第2行
case 0xB0: KEY0 = 2; break; //第3行
case 0x70: KEY0 = 3; break; //第4行
default: break;
}
P1 = 0x0F;
Tmp = P1;
switch (Tmp)
{
case 0x0E: KEY1 = KEY0 +0; break; //第1列 按健判断
case 0x0D: KEY1 = KEY0 +4; break; //第2列
case 0x0B: KEY1 = KEY0 +8; break; //第3列
case 0x07: KEY1 = KEY0 +12; break; //第4列
default: break;
}
return KEY1;
}
void main(void)
{
while(1)
{
P1 = 0xF0;
if (P1 != 0xF0);
keyscan();
P0 = DSY_CODE[KEY1];
}
}
//就是编译不了,提示有错误:
练习1.c(10): error C141: syntax error near '{'
练习1.c(12): error C231: 'P1': redefini
tion
练习1.c(12): error C231: 'P1': redefinition
练习1.c(13): error C231: 'Tmp': redefinition
练习1.c(13): error C247: non-address/-constant initializer
练习1.c(14): error C141: syntax error near 'switch'
练习1.c(15): error C129: missing ';' before '{'
Target not created
请问各位大神问题出在哪里呀?小弟在此先谢了。
矩阵键盘.rar 下载积分: 积分 -1 分
28.29 KB, 下载次数: 7, 下载积分: 积分 -1 分
一周热门 更多>