Using digital inputs in scripts
I’m working on a proof of concept just to play with the software and scripting. For fun, I connected a momentary switch between a digital input and ground. Added the device to BruControl as active low to turn on the pull up resistor. When I press the button, I get the appropriate response in the device status—ON when the button unpressed, OFF when pressed.
What I can’t seem to do is make use of that status in a script. I would like to have the script wait until the input is OFF, then do a number of things. Kind of like an digital kill switch—when pressed, turn off and disable a number of outputs.
How do I reference the value of the digital input in a script?
Hi. You can use the 'wait' statement to pause until the input changes. For example:
wait "Digital In 1" value == 0
or you can use a loop with the 'if' statement:
if "Digital In 1" value == 0 print "off" else print "on" endif sleep 3000 goto "loop"
Let me know if that doesn't make sense. Thanks!
Yes, but you have pointed out a couple of bugs we will address (thank you for that). True/False and on/off should work.
Also, the state is reporting incorrectly. With 'Active Low' on, a grounded pin should be a logical 'ON'. So note this will change in a next release of either software or firmware. In all candor, I am not sure how this happened - we are investigating, and I think this somehow got changed from a previous release. Thank you for pointing these out!