No, but there is a solution to put the action in one loop (main loop).
If I understand you well, you have the following scheme:
Time[s]
0..1 Loop 1
1..2 Nothing
2..3 Loop 2
3..4 Nothing
4..5 Loop 3
Define a variable that keeps track of the time.
Check against the current time (millis) and when within the correct 'range' perform an action.
After 5 seconds start over again.
uint32_t lastTime = -1;
void loop()
{
if (lastTime == -1)
{
lastTime = currentTime; // Initialization, can be done in setup too
}
uint32_t diffTime = millis() - lastTime;
if (diffTime < 1000) // 0..1 sec
{
DoLoop1();
}
else if (diffTime < 2000)
{
// Do nothing();
}
else if (diffTime < 3000)
{
DoLoop2();
}
else if (diffTime < 4000)
{
// Do nothing
}
else if (diffTime < 5000)
{
DoLoop3();
}
else // diffTime >= 5000
{
lastTime == currentTime; // Reset after 6 s
}
}
Update
Since you need all three loops together (and mixed), it's easier to define some variables.
bool loop1state, loop2state, loop3state; // True if running, false if off
int loop1index, loop2index, loop3index; // Iterator values
int periodIndex = 0; // starting with 0, increasing every 10 ms
Too bad I don't know the conditions when a loop starts, but let's say each iteration is 10 ms, and loop 1 starts immediately, loop 2 after 1000 ms, loop 3 after 1500 ms. After 3000 ms it starts all over.
void loop()
{
// Update loop enablers.
switch(periodIndex)
{
case 0:
loop1state = true;
loop1index = 0;
break;
case 1000:
loop2state = true;
loop2index = 0;
break;
case 1500:
loop3state = true;
loop3index = 0;
break;
case 4000:
periodIndex = 0;
break;
}
if (loop1state)
{
DoLoop1(loop1index++);
loop1state = loop1index < 256;
}
if (loop2state)
{
DoLoop2(loop2index++);
loop2state = loop2index < 256;
}
if (loop3state)
{
DoLoop3(loop3index++);
loop3state = loop3index < 256;
}
delay(10); // 10 ms
}
Note, not tested, but the idea shold be clear
New update
You should not do a full loop during each switch, but only one iteration of the loop.
I did not run the sketch, just out of my head.
Some tips: print out the variables during each loop, so you get a clear idea what is happening (so all loop states and indices, and the periodIndex).
int LED = 3;
int LED2 =10;
int LED3 = 9;
bool loop1state, loop2state, loop3state; // True if running, false if off
int loop1index, loop2index, loop3index; // Iterator values
int periodIndex = 0; // starting with 0, increasing every 10 ms
void setup()
{
Serial.begin(9600);
}
void loop()
{
// Update loop enablers.
switch(periodIndex)
{
case 0:
loop1state = true;
loop1index = 0;
break;
case 1000:
loop2state = true;
loop2index = 0;
break;
case 1500:
loop3state = true;
loop3index = 0;
break;
case 4000:
periodIndex = 0;
break;
}
if (loop1state)
{
analogWrite(LED,loop1index++);
loop1state = loop1index < 256;
}
if (loop2state)
{
analogWrite(LED2,loop2index++);
loop2state = loop2index < 256;
}
if (loop3state)
{
analogWrite(LED3,loop3index++);
loop3state = loop3index < 256;
}
periodIndex++;
delay(10);
}
goto
in arduino, not that you should...