Arduino Esp32 use millis() to put commands in sequence. Without delay

unsigned long then = 0;
unsigned long intervals[4] = { 0, 2000, 4000, 6000 };
int current_interval_index = 0;
void setup() {

void loop() {
    unsigned long now = millis();
    if (now - then >= intervals[current_interval_index]) {
        switch (current_interval_index) {
        case 0:
            Serial.println("Function 1");
        case 1:
            Serial.println("Function 2");
        case 2:
            Serial.println("Function 3");
        case 3:
            Serial.println("Function 4");
        then = now;
        current_interval_index = (current_interval_index + 1) % 4; // increment index and wrap it back to zero, if it goes to 4 
use millis to sequence
the miricle board

A high percentage of this code probably came from someone else. I do not know how to write code, but I can sometimes paste things together that work. Even if the code shown here did not come from one of the sources below, I most likely learned how to make it work with help from them. My apologies to anyone I missed. Please make use of anything you see here, but do not count on good coding practice as I have just done what was needed to make it work. But it does work, unless otherwise noted. Thanks to everyone who has shared their knowledge and good luck to those who are learning.


Please share it. Thanks!