How can i switch relay with heating load on at 30 seconds, then switch em off,...
A couple different approaches:
- use a timer: keep a free running timer that increments a software counter. Whenever a switch is turned on, record the reading of that free running timer; On future runs, test the counter to see if sufficient time has elapsed and act accordingly.
- use a loop counter: if your loop time is (fairly) constant, you can count the number of loops that have passed and use that to determine if sufficient time has gone by.