Im using a NodeMCU with multiple timer. This code is running properly. There are 3 timer functions that counting depends on input from firebase with delay on each. But when the delay comes, the other timer is stopped for a while until the delay is done. The code is showed below:
//timerrak1
void t2Callback() {
if (start[0] == milis[0]) {
Serial.println("TIMER1");
digitalWrite(selenoid[0], LOW);
digitalWrite(pompa, LOW);
delay(durasi[0]);
digitalWrite(pompa, HIGH);
digitalWrite(selenoid[0], HIGH);
t2.disable();
start[0] = 0;
}
start[0] = start[0] + 1000;
}
//timerrak2
void t4Callback() {
if (start[1] == milis[1]) {
Serial.println("TIMER2");
digitalWrite(selenoid[1], LOW);
digitalWrite(pompa, LOW);
delay(durasi[1]);
digitalWrite(pompa, HIGH);
digitalWrite(selenoid[1], HIGH);
t4.disable();
start[1] = 0;
}
start[1] = start[1] + 1000;
}
//timerrak3
void t5Callback() {
if (start[2] == milis[2]) {
Serial.println("TIMER3");
digitalWrite(selenoid[2], LOW);
digitalWrite(pompa, LOW);
delay(durasi[2]);
digitalWrite(pompa, HIGH);
digitalWrite(selenoid[2], HIGH);
t5.disable();
start[2] = 0;
}
start[2] = start[2] + 1000;
}
My question is how to make every timer's delay not affect another timer's function.