unsigned long timer, interval = 500;
int value, counter = 0; // a counter
void setup() {
Serial.begin(115200);
randomSeed(analogRead(A0));
}
void loop() {
if (millis() - timer > interval) { // program running longer than "interval"
timer = millis(); // store new "time zero"
if (counter > 3) {
Serial.println();
counter = 0; // check loop counter for overflow
}
value = random(4);
switch (value) { // select the function
case (0): { // if value is 0
function_0(); // call this function
break; // exit this case
}
case (1): {
function_1();
break;
}
case (2): {
function_2();
break;
}
case (3): {
function_3();
break;
}
}
counter++; // increment function counter
}
}
void function_0() {
Serial.print("f0 ");
}
void function_1() {
Serial.print("f1 ");
}
void function_2() {
Serial.print("f2 ");
}
void function_3() {
Serial.print("f3 ");
}