大家帮帮忙 程序查错
在keil编译 错误一大堆烦死了,大家帮帮忙看下 哪出问题了
先谢谢了
#include<reg51.h>
sbit p3_0=P3^0;
sbit p0_0=P0^0;
sbit p0_1=P0^1;
void delay(unsigned int k);
int cheak(unsigned char *jj);
void scankey();
int n=0;
main()
{
unsigned char code tab[7]={0xc0,0xf9,0xa4,0xb0,0xbf,0x86,0x8c};
unsigned char code mima[5]={0x01,0x00,0x01,0x00};
unsigned char data mimabuf[5];
P0=0xff;
while(1)
{
P1=tab[4];
p3_0=1;
n=0;
mimabuf[3]=255;
while(mimabuf[3]==255)
{
scankey();
}
if(cheak(mimabuf))
{
P1=tab[5];
p3_0=0;
}
}
}
void delay(unsigned int k)
{
unsigned char i;
unsigned int j;
for(j=0;j<k;j++)
for(i=0;i<255;i++);
}
void scankey()
{
if(p0_0==0)
{
delay(20);
if(p0_0==0)
{
P1=tab[1];
mimabuf[n++]=1;
}
while(p0_0==0);
}
if(p0_1==0)
{
delay(20);
if(p0_1==0)
{
P1=tab[0];
mimabuf[n++]=0;
}
while(p0_1==0);
}
}
int cheak(unsigned char *jj)
{
char i;
for(i=0;i<4;i++)
{
if(mima[i]!=jj[i])
{
return 0;
}
}
return 1;
}
[解决办法]
main() 改为void main(void)
mima[5] 与mimabuf[5] 定义在main()函数内,void scankey() 与 int cheak(unsigned char *jj) 是不能访问的。
另:键盘扫描写得有点理想化,没考虑按键抖动问题吧?