|
下面有标注的地方有错误,提示信息是“syntax error near 'else'”,出错的地方在下文中标出,请大家帮忙找一下,谢谢了
#include
unsigned char keyboard[]={0x7E,0xBE,0xDE,0xEE, //0,1,2,3
0x7D,0xBD,0xDD,0xED, //4,5,6,7
0x7B,0xBB,0xDB}; //8,9,sure
unsigned char search[]={0x7F,0xBF,0xDF,0xEF};
unsigned char keychange[8]={0,1,2,3,4,5,6,7};
unsigned char i,m,n=0,j=0;
bit flag=0;
sbit P3_0=P3^0;
sbit P3_1=P3^1;
sbit P3_2=P3^2;
sbit P3_3=P3^3;
sbit P3_4=P3^4;
sbit P3_5=P3^5;
unsigned char soso(unsigned char keynum);
void readkey(unsigned char number);
void inputkey(unsigned char key);
void delay200ms(void);
void delay1s(void);
void main()
{
P3_0=0;
while(1){
delay200ms();
do{P1=0x0F;
m=P1;}while(m==P1);
P3_3=0;delay1s();P3_3=0;
i=0;
do{P1=search;
m=P1; }while(m==search[i++]);
i=soso(m);
if(P3_1==0) {if(j<8) inputkey(i);
else {n=0;j=0;P3_5=0;delay1s();P3_5=1;};
};
else //????错误的箭头指向这行,提示“syntax error near 'else'”
{if(i==10) {if(flag==0) {P3_1=0;P3_0=1;}; //open
else {P3_5=0;delay1s();P3_5=1;};
n=0;j=0;flag=0;};
else readkey(i);
};
}//while
}//main
unsigned char soso(unsigned char keynum)
{ i=0;
while(keynum!=keyboard)
{++i;}
return i;
}
void readkey(unsigned char number)
{
if(n<8)
{if(number!=keychange[j++]) flag=1;
else ++j;}
else flag=1;
++n;
}
void inputkey(unsigned char key)
{
key=keychange[j++];
}
void int_0() interrupt 1
{
void delay200ms();
P3_1=1;
P3_0=0;//close
n=0;
j=0;
}
void delay200ms(void)
{ unsigned char a,b,c;
for(a=5;a>0;a--)
for(b=132;b>0;b--)
for(c=150;c>0;c--); }
void delay1s(void)
{ unsigned char a,b,c,d;
for(a=5;a>0;a--)
for(b=4;b>0;b--)
for(c=116;c>0;c--)
for(d=214;d>0;d--); }
|
|