I have a requirement where I need to turn a relay on after so many minutes. I got a function that works but while delay in progress to execute that, I cannot call any other function and give me an error that timerdelay has been disturbed. Is there a way to keep the delay active and use other functions or variable calls?
Here is my code in use:
int relayOnDelay(String command) {
// Ritual incantation to convert String into Int
char inputStr[64];
command.toCharArray(inputStr,64);
char *tempStr;
int i, delaySecs;
tempStr = strtok(inputStr, "|");
if (tempStr != NULL) {
i = atoi(tempStr);
}
tempStr = strtok(NULL, "|");
if (tempStr != NULL) {
delaySecs = atoi(tempStr);
}
// Turn the desired relay on after specified seconds of delay.
delay(1000*delaySecs);
myRelays.on(i);
// Respond
return 1;
}
Thanks.