keil c 的错误error C141: syntax error near '='
#include<reg51.h>#defineSW_PortP2;sbitbuzzer=P3^7;unsignedcharkeys;unsignedcharcodeto...
#include <reg51.h>
#define SW_Port P2;
sbit buzzer=P3^7;
unsigned char keys;
unsigned char code tone[]= {115, 102, 91, 86, 77, 68, 61, 57 };
void sound(unsigned char);
void delay8us(unsigned char);
main()
{ while (1)
{ SW_Port=0xff;
keys=~SW_Port;
switch (keys)
{ case 0x01:sound(0);break;
case 0x02:sound(1);break;
case 0x04:sound(2);break;
case 0x08:sound(3);break;
case 0x10:sound(4);break;
case 0x20:sound(5);break;
case 0x40:sound(6);break;
case 0x80:sound(7);break;
default:buzzer=1;break;
}
}
}
void sound(unsigned char x)
{ unsigned char i;
for (i=0;i<60;i++)
{ buzzer=0; delay8us(tone[x]);
buzzer=1; delay8us(tone[x]);}
}
void delay8us(unsigned char x)
{ unsigned char i,j;
for (i=0;i<x;i++)
for (j=0;j<1;j++);
}
这句出现错误 { SW_Port=0xff; 展开
#define SW_Port P2;
sbit buzzer=P3^7;
unsigned char keys;
unsigned char code tone[]= {115, 102, 91, 86, 77, 68, 61, 57 };
void sound(unsigned char);
void delay8us(unsigned char);
main()
{ while (1)
{ SW_Port=0xff;
keys=~SW_Port;
switch (keys)
{ case 0x01:sound(0);break;
case 0x02:sound(1);break;
case 0x04:sound(2);break;
case 0x08:sound(3);break;
case 0x10:sound(4);break;
case 0x20:sound(5);break;
case 0x40:sound(6);break;
case 0x80:sound(7);break;
default:buzzer=1;break;
}
}
}
void sound(unsigned char x)
{ unsigned char i;
for (i=0;i<60;i++)
{ buzzer=0; delay8us(tone[x]);
buzzer=1; delay8us(tone[x]);}
}
void delay8us(unsigned char x)
{ unsigned char i,j;
for (i=0;i<x;i++)
for (j=0;j<1;j++);
}
这句出现错误 { SW_Port=0xff; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询