boolean condition = true;
void setup() {
Serial.begin(115200);
}
void loop()
{
test();
}
void test() {
static boolean firstEntry = true;
static boolean callStuffC = false;
if (firstEntry) {
firstEntry = false;
doStuffA();
}
if (checkCondition()) {
doStuffB();
callStuffC = true;
} else {
if (callStuffC) {
callStuffC = false;
doStuffC();
}
doStuffA();
}
}
boolean checkCondition() {
static int count = 0;
count++;
if (count > 4) {
count = 0;
condition = !condition;
}
return condition;
}
void doStuff(char stuffChar) {
Serial.print("This is stuff");
Serial.println(stuffChar);
delay(500); // This delay only here to reduce the lines/second printed to the serial monitor
}
void doStuffA() {
doStuff('A');
}
void doStuffB() {
doStuff('B');
}
void doStuffC() {
doStuff('C');
}