@rwco ... I see this is creeping back in
// Check if millis rolled over
if (start_time2 > time_now2) start_time2 = millis();
There is no need to check for millis() rollover.
This
time_now = millis();
if (time_now - start_time > delay_time)
{
// Stop the actuator after delay_time
digitalWrite (RelayF_pin, LOW);
digitalWrite (RelayR_pin, LOW);
}
is how to do timing properly. It will function perfectly for intervals shorter than 49.7 days...
I have removed a variable and the comment, which leaps off the page to experienced readers and the rollover test and "solution", which analysis and testing show is not what you want and nothing you need to do.
In my version, both timers follow the idiomatic pattern
time_now = millis();
if (time_now - start_time > delay_time)
{
// Stop the actuator after delay_time. Once
if (digitalRead(RelayF_pin) == HIGH || digitalRead(RelayR_pin) == HIGH)
{
Serial.println(" AB timeout STOP");
digitalWrite (RelayF_pin, LOW);
digitalWrite (RelayR_pin, LOW);
}
}
Since I wanted to print the STOP message only once, I only do so if either of the following lines would actually turn off something that was on.
Here's three competent articles on the subject.
As I said, it's a common misconception. It has been done to death multiple times on these fora, always ending with the same conclusion and usually convincing ppl who come here worrying about it, or have been told here they must.
a7