keil代码好多错误不知道怎么修改啊有没有大佬指教一下
51hei_C语言文件.c(66): error C202: 'NS_led': undefined identifier
51hei_C语言文件.c(67): error C202: 'EW_led': undefined identifier
51hei_C语言文件.c(168): error C171: 'break': missing enclosing loop
51hei_C语言文件.c(169): error C172: 'case': missing enclosing switch
51hei_C语言文件.c(176): error C171: 'break': missing enclosing loop
51hei_C语言文件.c(177): error C172: 'case': missing enclosing switch
单片机源程序如下:
- #include<reg52.h>
- sbit EW_1=P1^0;
- sbit EW_2=P1^1;
- sbit NS_1=P1^2;
- sbit NS_2=P1^3;
- sbit add_red_time=P1^4;
- sbit add_green_time=P1^5;
- sbit reduce_red_time=P1^6;
- sbit reduce_green_time=P1^7;
- sbit EW_red=P2^0;
- sbit EW_green=P2^1;
- sbit EW_blue=P2^2;
- sbit NS_red=P2^3;
- sbit NS_green=P2^4;
- sbit NS_blue=P2^5;
- char count=0;
- char red_time=30;
- char green_time=25;
- char blue_time=0;
- char NS_second=0;
- char EW_second=0;
- char code smgduan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- char display_data[4]={0};
- char temp_data[4]={0};
- char NS_R_G_mode=0;
- char EW_R_G_mode=0;
- bit NS_R_G_flag=0;
- bit EW_R_G_flag=0;
- void delay(unsigned int i)
- {
- while(i--);
- }
- void Timer_init()
- {
- TMOD=0x01;
- TH0=0x3C;
- TL0=0xB0;
- EA=1;
- ET0=1;
- TR0=1;
- }
- void lnit()
- {
- P0=0x00;
- P2=0x00;
- EW_1=1;
- EW_2=1;
- NS_1=1;
- NS_2=1;
- NS_led=1;
- EW_led=1;
- NS_second=red_time;
- EW_second=green_time;
- blue_time=red_time-green_time;
- Timer_init();
- }
- void NS_SMG_drive(char*buff)
- {
- NS_1=0;
- NS_2=1;
- P0=~smgduan[buff[0]];
- delay(5);
- P0=0x00;
-
- NS_1=1;
- NS_2=0;
- P0=~smgduan[buff[1]];
- delay(5);
- P0=0x00;
-
- NS_1=1;
- NS_2=1;
- }
- void EW_SMG_drive(char*buff)
- {
- EW_1=0;
- EW_2=1;
- P0=~smgduan[buff[2]];
- delay(5);
- P0=0x00;
-
- EW_1=1;
- EW_2=0;
- P0=~smgduan[buff[3]];
- delay(5);
- P0=0x00;
-
- EW_1=1;
- EW_2=1;
- }
- void data_del(char*buff,char data1,char data2)
- {
- buff[0]=data1/10;
- buff[1]=data1/10;
- buff[2]=data2/10;
- buff[3]=data2/10;
- }
- void Time_del()
- {
- if(count>=20)
- {
- NS_second--;
- EW_second--;
- switch(NS_R_G_mode)
- {
- case 0:
- {
- if(NS_second<0)
- {
- NS_second=green_time;
- NS_R_G_mode=1;
- }
- }break;
- case 1:
- {
- if(NS_second<0)
- {
- NS_second=blue_time;
- NS_R_G_mode=2;
- }
- }break;
- case 2:
- {
- if(NS_second<0)
- {
- NS_second=red_time;
- NS_R_G_mode=0;
- }
- }break;
- default:break;
- }
- switch(EW_R_G_mode)
- case 0:
- {
- if(EW_second<0)
- {
- EW_second=green_time;
- EW_R_G_mode=1;
- }
- }break;
- case 1:
- {
- if(EW_second<0)
- {
- EW_second=blue_time;
- EW_R_G_mode=2;
- }
- }break;
- case 2:
- {
- if(EW_second<0)
- {
- EW_second=red_time;
- EW_R_G_mode=0;
- }
- }break;
- default:break;
- }
- count=0;
- }
- }
- void R_G_B_led()
- {
- switch(NS_R_G_mode)
- {
- case0:
- {
- NS_blue=0;
- NS_red=1;
- }break;
- case1:
- {
- NS_red=0;
- NS_green=1;
- }break;
- case2:
- {
- NS_blue=0;
- if(count<10)
- NS_blue=1;
- else
- NS_blue=0;
- }break;
- default:break;
- }
- switch(NS_R_G_mode)
- {
- case0:
- {
- EW_blue=0;
- EW_red=1;
- }break;
- case1:
- {
- EW_red=0;
- EW_green=1;
- }break;
- case2:
- {
- EW_blue=0;
- if(count<10)
- EW_blue=1;
- else
- EW_blue=0;
- }break;
- default:break;
- }
- }
- void Set_time()
- {
- if((add_red_time==0)||(add_green_time==0)||(reduce_red_time==0)||(reduce_green_time==0))
- {
- TR0=0;
- P2=0x00;
- EW_led=1;
- NS_led=1;
- while(1)
- {
- data_del(temp_data,red_time,green_time);
- NS_SMG_drive(temp_data);
- EW_SMG_drive(temp_data);
- if(add_red_time==0)
- {
- delay(5);
- if(add_red_time==0)
- {
- red_time++;
- if(red_time>99)
- red_time=99;
- data_del(temp_data,red_time,red_time)£?
- NS_SMG_drive(temp_data);
- }while(!add_red_time);
- }
- if(add_green_time==0)
- {
- delay(5);
- if(add_green_time==0)
- {
- green_time++;
- if(green_time>95)
- green_time=95;
- data_del(temp_data,green_time,green_time);
- EW_SMG_drive(temp_data);
- }while(!add_green_time);
- }
- if(reduce_red_time==0)
- {
- delay(5);
- if(reduce_red_time==0)
- {
- red_time--;
- if(red_time<10)
- red_time=10;
- data_del(temp_data,red_time,red_time);
- NS_SMG_drive(temp_data);
- }while(!reduce_red_time);
- }
- if(reduce_green_time==0)
- {
- delay(5);
- if(reduce_green_time==0)
- {
- green_time--;
- if(green_time<5)
- green_time=5;
- data_del(temp_data,green_time,green_time);
- EW_SMG_drive(temp_data);
- }while(!reduce_green_time);
- }
复制代码
|