Forum

Using digital input...
 
Notifications
Clear all

Using digital inputs in scripts

5 Posts
2 Users
0 Likes
5,124 Views
(@deadsalmon)
New Member
Joined: 6 years ago
Posts: 4
Topic starter  

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)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

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: 6 years ago
Posts: 4
Topic starter  

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


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

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: 6 years ago
Posts: 4
Topic starter  

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: