那位大侠给我分析一下为什么用 keil编译不了!谢谢!P1为按键(独立式)P2是二极管
#include<REG51.H>
#define uchar unsigned char
#define uint unsigned int
char a=0;
void key (void);
void delay (uint);
void dong (void);
void main(void)
{
while(1){
uchar i;
key();
switch (a)
{
case 0xfe:
{P2=0x00;
delay(500);
P2=0xff;
delay(500);
}break;
case 0xfd:
{ dong();
} break;
case 0xfb:
{ char j=0xff;
for (i=0;i<8;i++)
{
j=j<<1;
P2=j;
delay (500);
}
} break;
case 0xf7:
{ char x=0xff;
for (i=0;i<8;i++)
{
x=x>>1;
P2=x;
delay (500);
}
} break;
}
}
void delay (uint k) 总在则一行提示出错!
{ uint i,j;
for (i=0;i<k;i++)
{for(j=0;j<121;j++){;}
}
}
void key (void)
{ P1=0xff;
if (P1!=0xff)
{delay(10);
if (P1!=0xff)
a=P1;
}
} void dong (void)
{ P1=0x0f;
delay(500);
P2=0xf0
delay(500);
} |