这是我编的程序:::
#include
#define uchar unsigned char
#define uint unsigned int
sbit key(1)=P3^0;
sbit key(2)=P3^1;
sbit key(3)=P3^2;
sbit key(4)=P3^3;
sbit key(5)=P3^4;
sbit key(6)=P3^5;
sbit LED1=P1^2;
sbit LED2=P1^3;
sbit LED3=P1^4;
sbit LED4=P1^5;
sbit LED5=P1^6;
sbit LED6=P1^7;
void delayms(uint);
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void main(void)
{
while(1)
{
if(key(1)==1)
{
delayms(10);
if(key(1)==1)
LED1=0; LED3=0; LED2=1;LED4=1;
delayms(250);
}
if(key(2)==1)
{
delayms(10);
if(key(2)==1)
LED=0;LED4=0;LED1=1;LED3=1;
delayms(250);
}
bit LED1_buf,LED2_buf,LED_change_sign;
if((key(3) == 0) && (LED_change_sign == 0)) //在LED1,LED2状态没变的时候存入缓存,LED_change_sign为LED状态变化标志位。
{
LED1_buf = LED1;
LED2_buf = LED2;
}
if(key(3)==1)
{
delayms(10);
if(key(3) == 1)
{
if(LED1 == 0)
{
LED1 = 1;
LED_change_sign = 1;
}
if(LED2 == 0)
{
LED2 = 1;
LED_change_sign = 1;
}
}
else
{
LED1 = LED1_buf;
LED2 = LED2_buf;
LED_change_sign = 0;
}
bit LED3_buf,LED4_buf,LED_change_sign;
if((key(4) == 0) && (LED_change_sign == 0)) //在LED1,LED2状态没变的时候存入缓存,LED_change_sign为LED状态变化标志位。
{
LED1_buf = LED1;
LED2_buf = LED2;
}
if(key(4)==1)
{
delayms(10);
if(key(4) == 1)
{
if(LED3 == 0)
{
LED3 = 1;
LED_change_sign = 1;
}
if(LED4 == 0)
{
LED4 = 1;
LED_change_sign = 1;
}
}
else
{
LED3 = LED3_buf;
LED4 = LED4_buf;
LED_change_sign = 0;
}
if(key(5)==1)
{
delayms(10);
if(key(5)==1)
LED5=~LED5;
while(key(5)==1);
delayms(250);
}
if(key(6)==1)
{
delayms(10);
if(key(6)==1)
LED1=1;LED2=1;LED3=1;LED4=1;
while(key(6)==1);
delayms(250);
}
}
}
}
}
但下面显示:
Build target 'Target 1'
assembling STARTUP.A51...
compiling 12345.c...
12345.C(5): error C141: syntax error near '(', expected '='
12345.C(6): error C141: syntax error near '(', expected '='
12345.C(7): error C141: syntax error near '(', expected '='
12345.C(8): error C141: syntax error near '(', expected '='
12345.C(9): error C141: syntax error near '(', expected '='
12345.C(10): error C141: syntax error near '(', expected '='
Target not created
跪求解答