![]() |
|
Double timer, with time on and off - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Double timer, with time on and off (/showthread.php?tid=4382) |
Double timer, with time on and off - davidchispas - 15.11.2022 Hello, any example of a script for a timer with active operating time and resting time? I have a 1 bit signal from a presence detector. When this signal is activated, I need to create a cycle of: activating a bomb for 5 minutes and then deactivating it for 15 minutes. If after this time cycle, the detector signal is still active or is activated again, repeat the cycle. RE: Double timer, with time on and off - admin - 16.11.2022 Event script: Code: if event.getvalue() then
storage.set('presence_time', os.time())
endResident script with sleep time set to 1 second: Code: curr_trig_time = storage.get('presence_time', 0)
if not prev_trig_time then
prev_trig_time = curr_trig_time
end
if curr_trig_time > prev_trig_time then
prev_trig_time = curr_trig_time
grp.write('0/0/2', true)
os.sleep(5 * 60)
grp.write('0/0/2', false)
os.sleep(15 * 60)
end |