View Full Version : Toggling boolean using 2 limit switches
02-02-2009, 04:58 PM
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?
02-02-2009, 05:05 PM
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 :)
02-02-2009, 10:43 PM
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.
 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-2013, Jelsoft Enterprises Ltd.