B.C(50): error C161: 'Z': formal parameter ignoredTarget not created 编译错误!
- /************************************************************/
- /* 程序名:可控流水灯 */
- /* 功能:实现流水灯的方向、速度、亮度控制 */
- /* 硬件:P2 接开关,P1接LED ,数码管显示。 */
- /************************************************************/
- #include<reg52.h>
- #include <intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
-
- sbit K1=P2^0; //方向
- sbit K2=P2^1; //加速
- sbit K3=P2^2; //减速
- sbit K4=P2^3; //加亮
- sbit K5=P2^4; //变暗
- unsigned char Speed,LED;
- unsigned int tCount=0;
- unsigned char Idx; //速度取值索引
- unsigned char DelayMS;
- bit Dirtect=1; //滚动方向
-
- char duty=10; //占空比
- unsigned int code sTable[]={0,1,3,7,9,15,30,50,100,200,230,280,300,350}; //调速表
- unsigned char code seg_table[ ]={0xc0,0xf9,0xa4,0xb0,
- 0x99,0x92,0x82,0xf8,
- 0x80,0x90,0x88,0x83,
- 0xc6,0xa1,0x86,0x8e
- }; //数组缺少 [ ] ,要加code
- void delay_key(int i)
- {
- for (i=0;i<0;i++);
- P1=0x00;
- while(1)
- {
-
-
- unsigned char delay_key(Z);
- void delay_key(unsigned int Z )
- while(Z--) for(i=0;i<9;i++);
-
- }
-
- P1=seg_table[i];
- i=(i+1)%10;/*显示0-9*/
- delay_key(200);
-
- }
- void InitTimer0_Timer1(void);
- void delay(unsigned int x)
- {
- unsigned char i;
- while(x--) for(i=0;i<20;i++);
- }
- unsigned char GetKey(void)
- {
- unsigned char K;
- if(P2==0xFF) return 0;
- delay(10);
- switch(P2)
- {
- case 0xFE:K=1;break;
- case 0xFD:K=2;break;
- case 0xFB:K=3;break;
- case 0xF7:K=4;break;
- case 0xEF:K=5;break;
- default: K=0;break;
- }
- while(P2!=0xFF); //等待释放按键
- return K;
- }
- void KeyProcess(unsigned char Key)
- {
- switch(Key)
- {
- case 1:Dirtect=~Dirtect;break; //方向
- case 2:if(Idx>1) Speed=sTable[--Idx];break;//加速
- case 3:if(Idx<15) Speed=sTable[++Idx];break;//减速
- case 4:duty++;if(duty>=20) duty=20;break; //加亮
- case 5:duty--;if(duty<=0) duty=1; break;//变暗
- }
- }
- void main()
- {
- unsigned char Key;
- P0=P2=P1=0xFF;
- Idx=4;
- Speed=sTable[Idx];
- IP=0x02; //中断优先级
- InitTimer0_Timer1();
- LED = 0xfe;
- P0 = LED;
- while(1)
- {
- Key=GetKey();
- if(Key!=0) KeyProcess(Key);
- }
- }
- /******************************************************************/
- /* 定时器0和定时器1初始化 */
- /******************************************************************/
- void InitTimer0_Timer1(void)
- {
- TMOD = 0x20;
- TH1 = 0x06;
- TL1 = 0x06;
- EA = 1;
- ET0 = 1;
- TR0 = 1;
- ET1 = 1;
- TR1 = 1;
- }
- /******************************************************************/
- /* 定时器中断函数 */
- /******************************************************************/
- void timer0(void) interrupt 1
- {
- if(++tCount<Speed) return;
- tCount=0;
- if(Dirtect==1) LED = _cror_(LED,1); //循环右移1位,点亮下一个LED
- else LED=_crol_(LED,1);
- P0=LED;
- }
- void Timer1(void) interrupt 3 //调节占空比
- {
- static char t=0;
- t++;
- if(t==20)
- {
- t=0;
- P0=(0x00|LED);
- }
- if(duty==t) P0=0xFF;
- }
复制代码
|