Help a beginner, is there a way to set digital outputs say [2 to 7] on or off all at once instead of switching each individually. I am using a Led light tower; it is working but instead of multiple lines of code was wondering can i do this with less lines of code.
similar to what @dpeva said the easiest thing is to create a script function and then simply call that with the state that you want. A simple implementation could be
def set_standard_digital_outputs(startPort, state) # state would be an array of booleans equal to the number of outputs you want to control
local port = startPort
local endPort = startPort + length(state)
while port<endPort:
set_standard_digital_out(port, state[port])
port = port +1
end
end
In your program, you would add a script line and then you could pass it the state as an array of booleans telling it to turn on or off as well as the port to start at for instance