#include
#define uint unsigned int
#define uchar unsigned char
sbit led3=P0^0;
sbit led2=P0^1;
sbit led1=P0^2;
sbit sound=P2^6;
sbit led4=P2^7;
int newcode[6];
int mima[6]={1,2,3,4,5,6};
int cod[6];
uchar compf;
uchar comp;
uchar keyin;
uchar count=0;
uint i;
uchar shuru;
void delayms(uint ms)
{uint i;uint j;uint k;
for(i=0;i
{ for(j=0;j<100;j++);
for(k=0;k<102;k++);
}
}
/* 键扫描函数 */
uchar key_scan() // 键盘扫描
{
uchar temp,com1,com2;
uchar com;
P1=0xf0;
while(P1!=0xf0){
delayms(30);
if(P1!=0xf0)
{
com1=P1;
P1=0x0f;
com2=P1;
temp=com1|com2;
if(temp==0xee)com=0x03;
if(temp==0xed)com=0x02;
if(temp==0xeb)com=0x01;
if(temp==0xe7)com=0x0c;//修改键
if(temp==0xde)com=0x06;
if(temp==0xdd)com=0x05;
if(temp==0xdb)com=0x04;
if(temp==0xd7)com=0x0f;//无效
if(temp==0xbe)com=0x07;
if(temp==0xbd)com=0x08;
if(temp==0xbb)com=0x09;
if(temp==0xb7)com=0x0f;//无效
if(temp==0x7e)com=0x0b; //开锁
if(temp==0x7d)com=0x00;
if(temp==0x7b)com=0x0d; //确认
if(temp==0x77)com=0x0a;//清除
return(com);
}
}
}
int inputs(void)
{
int rece;
rece=key_scan();
if (rece>=0x00&&rece<=0x09)
{
return(rece);
}
else
{
return(0x0f);
}
}
uchar comparecode()
{
int g;
for(g=0;g<6;g++)
{
if(cod[g]==mima[g])
{
compf=1;
}
else
{
compf=0;
break;
}
}
return(compf);
}
void main(void)
{
led1=1;
led2=1;
led3=1;
led4=1 ;
sound=1;
shuru=0;
while(1)
{
while(shuru==0)
{
for(i=0;i<6;i++)
{
keyin=inputs();
while (keyin==0x0f)
{
cod[6]={0};
keyin=inputs();
}
led1=0; delay(30);led1=1;
cod=keyin;
shuru=1;
}
}
compf=comparecode();
if (compf==1)
{
led3=0;delay(30);led3=1;
led4=0; delay(30);led4=1;
cod[]={0};
}
else
{
count++;
led2=0;delay(30) ; led2=1;
sound=0;delay(30);spund=1;
while (count==3)
{
delay(100);
count=0;
}
while(count!=3)
{
shuru=0;
}
}
}
}
TEST2.C(112): error C141: syntax error near '{'
TEST2.C(112): error C141: syntax error near '}'
请教该怎么改啊?
回复 楼主 crazy258 的帖子
TEST2.C(112): error C141: syntax error near '{'
首先你应该知道这写单词的意思就是说在哪一行的地方有错误,具体的就是说你的括号不匹配!
void main(void)
{
led1=1;
led2=1;
led3=1;
led4=1 ;
sound=1;
shuru=0;
while(1)
{
看了半天,我想请你是不是这个while的括号没有匹配呢?
或者说主函数的最后的好没有匹配
你在最后一行加一个反括号 } 看看!
我的邮箱gaoxiaoan123@163.com!回帖是一种美德!互相帮助,共同进步!
口头禅:生活在于创造机会,把握机会!