单片机独立按键程序

2024-11-26 23:38:15
推荐回答(4个)
回答1:

你声名是这样:uchar anjian (uint n); 
具体定义的时候变成样:uchar anjian ()
你觉得参数没问题?

回答2:

#include
#include
#define uint unsigned int
#define uchar unsigned char
void yanshi(uint n);
uchar anjian ();
uchar dian ,bb;
#define js P1
#define ld P0

void yanshi (uint n)
{
uint j,i;
for (j=n;j>0;j--)
for (i=110;i>0;i--);
}
uchar anjian ()
{
uchar i;
if( js != 0xff )
{
yanshi(400);
if( js != 0xff )
{
dian=js;
i=0;
while ((i<50)&&(js!=0xff))
{
yanshi(10);
i++;
}
}
}
return dian;
}

void main(){
ld=0x00;
while (1){
switch (anjian()){
case (0xfe):
ld = 0x01;
break;
case (0xfd):
ld =0x02;
break;
case (0xfb):
ld =0x04;
break;
case (0xf7):
ld =0x08;
break;
case (0xef):
ld =0x10;
break;
case (0xdf):
ld =0x20;
break;
case (0xbf):
ld =0x40;
break;
case (0x7f):
ld =0x80;
break;
default :
break;
}
}
}

回答3:

这是你的声明
uchar anjian (uint n);
这是你的源程序,好好检查一下吧
uchar anjian ()
{
uchar i;
if( js != 0xff )
{
yanshi(400);
if( js != 0xff )
{
dian=js;
i=0;
while ((i<50)&&(js!=0xff))
{
yanshi();
i++;
}
}
}
return dian;
}

回答4:

第6行,uchar anjian (uint n); 这个原型有错误,与后面的调用和声明对应不起来。