// calling functions
unsigned long timer, interval = 1500; // timing variables in milliseconds
int counter = 0; // a counter
byte functions = 5; // the number of functions available (f0 through f4)
void setup() {
Serial.begin(115200);
}
void loop() {
if (millis() - timer > interval) { // program running longer than "interval"
timer = millis(); // store new "time zero"
if (counter > functions - 1) { // check counter
Serial.println(); // new line
counter = 0; // reset counter
}
switch (counter) { // check value
case (0): { // if 0
function_0(); // call function
break; // exit this case
}
case (1): {
function_1();
break;
}
case (2): {
function_2();
break;
}
case (3): {
function_3();
break;
}
case (4): {
function_4();
break;
}
default: break;
}
counter++; // increment function counter
}
}
void function_0() {
Serial.print("f0 Never ");
}
void function_1() {
Serial.print("f1 gonna ");
}
void function_2() {
Serial.print("f2 give ");
}
void function_3() {
Serial.print("f3 you ");
}
void function_4() {
Serial.print("f4 up ");
}