Forum

Using digital input...
 

Using digital inputs in scripts  

  RSS

(@deadsalmon)
New Member
Joined: 2 years ago
Posts: 4
November 19, 2017 4:28 pm  

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?

 

Jay


Quote
(@pbruno3)
Estimable Member Admin
Joined: 2 years ago
Posts: 241
November 19, 2017 5:28 pm  

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!


ReplyQuote
(@deadsalmon)
New Member
Joined: 2 years ago
Posts: 4
November 19, 2017 6:43 pm  

Thanks. 0 is the key. I was trying true and false...


ReplyQuote
(@pbruno3)
Estimable Member Admin
Joined: 2 years ago
Posts: 241
November 19, 2017 6:49 pm  

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!


ReplyQuote
(@deadsalmon)
New Member
Joined: 2 years ago
Posts: 4
November 19, 2017 8:23 pm  

Thank you for this information. I was struggling with the logic on the input. It was reporting ON, which I assumed was from the 5V on the line, but as you point out, when active low is selected, 5V should be OFF. 


ReplyQuote
Share: