struct Task {
const char* name;
unsigned long executionTime;
unsigned long period;
unsigned long lastRun;
};
Task tasks[] = {
{"Tache1",100,300,0},
{"Tache2",200,500,0},
{"Tache3",50,700,0}
};
const int numTasks = sizeof(tasks)/ sizeof(tasks[0]);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
unsigned long currentTime = millis();
for (int i = 0; i< numTasks ; i++){
if(currentTime - tasks[i].lastRun >= tasks[i].period){
Serial.print("l'Exécution de ");
Serial.println(tasks[i].name);
delay(tasks[i].executionTime);
tasks[i].lastRun = currentTime;
}
}
}