Okay so I’m using millis to manage time and when the set amount of time has passed I want to activate a if loop with four different values (i<=3 i++).
The problem is that I want the code to first do i==0 then go back to millis until set time has passed then do i==1 and so on. Is there any way the loop can remember which value i has?
Yes.
Declare a variable, set its value and use it in the for() loop instead of declaring the new variable inside the for()
Just as an example of what @arduino_new has said, try this code,
void setup()
{
Serial.begin(38400);
byte i = 0;
byte limit = 4;
for (;i < limit; i++)
{
Serial.println(i);
if (i == 3)
{
Serial.println("==========");
limit = 8;
}
}
Serial.println("==========");
limit = 12;
for (;i < limit; i++) {Serial.println(i);};
}
void loop()
{
}
So you want use the first for from 0 to 7 and the other from 8 to 11?
And what about millis()?