View Full Version : Toggling boolean using 2 limit switches
Quarkster
02-02-2009, 16:58
My robot has 2 limit switches. I want a certain value to be positive or negative depending on which of the switches was hit most recently. How would I do that?
Jared Russell
02-02-2009, 17:05
This is how I would do it in C:
boolean myBool = false;
if( switch1 )
myBool = true;
else if( switch2 )
myBool = false;
// If neither switch is pressed, then myBool keeps its old value
Making a VI out of that is left as an exercise to the reader :)
Burmeister #279
02-02-2009, 22:43
i can help make the VI for you or show you at least how it should be done but i need to know which limit switch you want to use to make the value positive. its complicated because i don't know if the value is, say 1, or if its a changing value. generally if its a motor you can use either selectors or multiple Case structures to choose your value.
[edit] i've made a simple series of cases here that should help you along. if you still can't figure it out, i'll be back on between 3-4 or 9ish
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.