LogicMachine Forum
Blink Output LM5R - 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: Blink Output LM5R (/showthread.php?tid=6397)



Blink Output LM5R - Frank68 - 20.04.2026

Hi

I need a digital output from the reactor that makes a lamp flash. Is it possible to create a reusable function that does this, passing it the flashing time?

Thank you very much.


RE: Blink Output LM5R - Daniel - 20.04.2026

Resident script, get value and write back 'not value'


RE: Blink Output LM5R - admin - 20.04.2026

Add to Common functions:
Code:
function blink(event, addr, delay)
  local obj = grp.find(addr)
  if not event.getvalue() then
    obj:write(false)
    return
  end
 
  local value = obj.value
  while true do
    value = not value
    obj:write(value)
    os.sleep(delay)
  end
end

Create a boolean object and map an event script to it. Set Execution mode to "Last instance only".
0/0/2 is the output control group address.
3 is delay in seconds between each on/off.
Code:
blink(event, '0/0/2', 3)

Writing true to the event script object will start the blinking. Writing false will stop it and will turn the output off.