automatic transfer switch

my question:
what is the best way to measure a digital input with an interval of 25 seconds.
when it is measured as LOW at the beginning , I would like to measure again after 25 seconds whether it is still LOW and then take appropriate action. In the mean time nothing should actually happen.

What to use??

interrupt routine, use of millis() or delay function, or even other??

project: measure AC power and is it down for more than 25 seconds , start the generator via relay and remote terminal, when mains power is back , stop the generator. I have a mechanical ATS (see picture) which automatic switches the load from mains to generator.
ats2 shows how electronic ats works..

thanks in advance
Leo Smit

ats.jpg

Use millis.

Other folks have done this. Generally, you power the Arduino via a rechargeable battery that's always on its charger. Use another 5VDC wall wart to detect whether AC power is up.

When you notice an outage, use millis to note when it started. If power comes back within 25 seconds go back to looking for an outage, if not, start the generator via a relay - often an opto-isolated one.

thanks for your reply, I will try the millis()
and the relay
Leo Smit