I hope this helps...
const byte NUM_STEPS = 3;
byte currStep;
// see blink without delay example
unsigned long prevMillis;
// execute a new step every "interval" milliseconds
unsigned long interval = 1000; // 1 s to avoid flooding the serial terminal with Serial.println() statements
// perform the expected action(s) for the specified step number
void executeStep(byte stepNumber) {
switch(stepNumber) {
case 0:
// just an example...
Serial.println("executing step 0");
break;
case 1:
Serial.println("executing step 1");
break;
case 2:
Serial.println("executing step 2");
break;
default:
// this is just to help debugging
Serial.println("Unexpected step number!");
break;
}
}
void setup() {
Serial.begin(115200);
// start from first step
currStep = 0;
// execute first step
executeStep(currStep);
}
void loop() {
// see blink without delay example...
// if the time has come to process the next step...
if (millis() - prevMillis >= interval) {
prevMillis = millis();
// switch to next step
currStep++;
// restart if needed
if (currStep >= NUM_STEPS) {
currStep = 0;
}
// execute the new step
executeStep(currStep);
}
}