单片机课做的作业,目的是同时亮灯和蜂鸣器播放八月桂花,但是一直出现
133.c(72): error C141: syntax error near 't', expected ')'错误
求帮助
- #include <reg52.h>
- #include <intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- sbit Beep=P1^5;
- unsigned char n=0;
- unsigned char code music_tab[]={
- 0x18, 0x30, 0x1C , 0x10,
- 0x20, 0x40, 0x1C , 0x10,
- 0x18, 0x10, 0x20 , 0x10,
- 0x1C, 0x10, 0x18 , 0x40,
- 0x1C, 0x20, 0x20 , 0x20,
- 0x1C, 0x20, 0x18 , 0x20,
- 0x20, 0x80, 0xFF , 0x20,
- 0x30, 0x1C, 0x10 , 0x18,
- 0x20, 0x15, 0x20 , 0x1C,
- 0x20, 0x20, 0x20 , 0x26,
- 0x40, 0x20, 0x20 , 0x2B,
- 0x20, 0x26, 0x20 , 0x20,
- 0x20, 0x30, 0x80 , 0xFF,
- 0x20, 0x20, 0x1C , 0x10,
- 0x18, 0x10, 0x20 , 0x20,
- 0x26, 0x20, 0x2B , 0x20,
- 0x30, 0x20, 0x2B , 0x40,
- 0x20, 0x20, 0x1C , 0x10,
- 0x18, 0x10, 0x20 , 0x20,
- 0x26, 0x20, 0x2B , 0x20,
- 0x30, 0x20, 0x2B , 0x40,
- 0x20, 0x30, 0x1C , 0x10,
- 0x18, 0x20, 0x15 , 0x20,
- 0x1C, 0x20, 0x20 , 0x20,
- 0x26, 0x40, 0x20 , 0x20,
- 0x2B, 0x20, 0x26 , 0x20,
- 0x20, 0x20, 0x30 , 0x80,
- 0x20, 0x30, 0x1C , 0x10,
- 0x20, 0x10, 0x1C , 0x10,
- 0x20, 0x20, 0x26 , 0x20,
- 0x2B, 0x20, 0x30 , 0x20,
- 0x2B, 0x40, 0x20 , 0x15,
- 0x1F, 0x05, 0x20 , 0x10,
- 0x1C, 0x10, 0x20 , 0x20,
- 0x26, 0x20, 0x2B , 0x20,
- 0x30, 0x20, 0x2B , 0x40,
- 0x20, 0x30, 0x1C , 0x10,
- 0x18, 0x20, 0x15 , 0x20,
- 0x1C, 0x20, 0x20 , 0x20,
- 0x26, 0x40, 0x20 , 0x20,
- 0x2B, 0x20, 0x26 , 0x20,
- 0x20, 0x20, 0x30 , 0x30,
- 0x20, 0x30, 0x1C , 0x10,
- 0x18, 0x40, 0x1C , 0x20,
- 0x20, 0x20, 0x26 , 0x40,
- 0x13, 0x60, 0x18 , 0x20,
- 0x15, 0x40, 0x13 , 0x40,
- 0x18, 0x80, 0x00
- };
- void int0() interrupt 1
- {
- TH0=0xd8; TL0=0xef; n--;
- }
- void delay(unsigned char m)
- {
- unsigned i=3*m; while(--i);
- }
- void delayms(unsigned char a)
- {
- while(--a);
- }
- void delay(unit t)
- {
- register uint bt;
- for(;t;t--) ;
- for(bt=0;bt<255;bt++);
- }
- void ledlight()
- {
- uint i;
- uchar temp;
- while(1)
- {
- temp=0x01;
- for(i=0;i<8;i++)
- {
- P2=~temp;
- delay(100);
- temp<<=1;
- }
- temp=0x80;
- for(i=0;i<8;i++)
- {
- P2=~temp;
- delay(100);
- temp>>=1;
- }
- temp=0xFE;
- for(i=0;i<8;i++)
- {
- P2=temp;
- delay(100);
- temp<<=1;
- }
- temp=0x7F;
- for(i=0;i<8;i++)
- {
- P2=temp;
- delay(100);
- temp>>=1;
- }
- }
- }
- void delay(uint t)
- {
- register uint bt;
- for(;t;t--)
- for(bt=0;bt<255;bt++);
- }
- void main(void)
- {
- uint i;
- uchar temp;
- while(1)
- {
- temp=0x01;
- for(i=0;i<8;i++)
- {
- P2=~temp;
- delay(100);
- temp<<=1;
- }
- temp=0x80;
- for(i=0;i<8;i++)
- {
- P2=~temp;
- delay(100);
- temp>>=1;
- }
- temp=0xFE;
- for(i=0;i<8;i++)
- {
- P2=temp;
- delay(100);
- temp<<=1;
- }
- temp=0x7F;
- for(i=0;i<8;i++)
- {
- P2=temp;
- delay(100);
- temp>>=1;
- }
- }
- }
- void main()
- {
- unsigned char p,m;
- unsigned char i=0;
- TMOD&=0x0f;
- TMOD|=0x01;
- TH0=0xd8;
- TL0=0xef;
- IE=0x82;
- play:
- while(1)
- {
- a: p=music_tab[i];
- if(p==0x00) {i=0,delayms(1000);goto play;
- ledlight;}
- else if(p==0xff) {i=i+1;delayms(100);TR0=0;goto a;}
- else {m=music_tab[i++],n=music_tab[i++];}
- TR0=1;
- while(n!=0) Beep=~Beep,delay (m);
- TR0=0;
-
-
-
- }
- }
复制代码 |