根据分析,你的代码是要所有灯
挨着顺序间隔1秒闪烁一次,
挨着顺序间隔半秒闪失2次,
挨着顺序间隔250毫秒闪烁5次。
下面是我的代码,你看看 能否达到你的效果
[mw_shl_code=c,true]#define TYPE_1 1000
#define TYPE_2 500
#define TYPE_3 250
int ledPin[5]={1,3,5,7,9};
int type ;
void setup()
{
type = TYPE_1;
for (int i = 0; i < 5; i++)
pinMode(ledPin,OUTPUT);
}
void loop()
{
int delayTime = 0;
int repeat = 0;
switch (type)
{
case TYPE_1:
delayTime = 1000;
repeat = 1;
type = TYPE_2;
break;
case TYPE_2:
delayTime = 500;
repeat = 2;
type = TYPE_3;
break;
case TYPE_3:
delayTime = 250;
repeat = 5;
type = TYPE_1;
}
while (--repeat > -1)
{
for (int i = 0; i < 5; i++)
{
int led = ledPin;
digitalWrite(led, HIGH);
delay(delayTime);
digitalWrite(led, LOW);
delay(delayTime);
}
}
}[/mw_shl_code] |