I want my arm to go specific positions when I push on some buttons. It seems what I ve done with case structure is complicated. Do I have any other simplier way to solve this button issue? Maybe with just one structure.

Thanks in advance!!!

buttonexample.vi (15.6 KB)

buttonexample.vi (15.6 KB)

Here’s a simpler button selection structure.
There is an example for joystick buttons and a second example for custom controls through the Cypress I/O.
It just has a case for each button on the joystick.

I’d recommend making a control of each value you put inside each case, so you can adjust them all in one place on the front panel instead of digging through the cases.

I’d recommend making a control of each value you put inside each case, so you can adjust them all in one place on the front panel instead of digging through the cases.

Good Idea just make sure to set the control value as the default (right click set as default) before you run the code without the computer or it will use the original value

Mark can you please tell me basically what your code does? Because just copy-pasting will not help me.


This code at it’s heart, just searches for the first True button, and tells you which one it found, if any.

The 12-possible buttons from the joystick come in as a cluster, so the code first converts that cluster into an array, so it can use one of the built-in array manipulation functions.
(Note that the Cypress I/O board inputs already come as an array of values.)

So we have an array of true/false values for each of the 12 possible buttons.
True if the button is being pushed, False if it is not being pushed.

Programming->Array has a simple function called Search 1D array that simply searches an input array for the value you specify. It returns the index into the array where it finds the first value that matches.
It returns a -1 if it cannot find that value at all.
The buttons in the array start with button 1 in the 0 array position.
So we get an index from -1 to 11 if we search the array for the first True value.

If we add 1 to that index we get out, our range is now 0-12.
0 now = no button pushed, and 1-12 is the button that is being pushed.

In this case we hand it the array of buttons and ask it to tell us the first one that is True.
If multiple buttons are being pushed, then it only recognizes the lowest number button and ignores any higher ones that might also be pushed at the same time.

Attach a case statement to the output index and you can make cases for each of the buttons you care about.
So, for instance, if you are using the trigger (button 1) elsewhere, your case statement can ignore it and only have cases for buttons 3-7. Default and no button would catch the others, or you could have cases for the extras that just do nothing with them.

You could even easily write your own code to search the button cluster for true values.

The joystick example shows “Button 1” only so you can see what cluster the other code is manipulating. It isn’t necessary or used.

Thank you Mark!

As of right now our buttons are set up as momentary. What we want it to do is when we push a button a cylinder goes out and when we push that same button it retracts. From a programming side I guess I’m asking how exactly a person would do this.

LabVIEW Examples look for the one named Button Toggle Action.
It’s about halfway down the page.
I think that’s what you want.

There is also a VI for this provided in the examples NI wrote. Check out

Program Files >> National Instruments >> LabVIEW 8.6 >> examples >> FRC >> Driver Station Inputs >> Joystick Button Latching >> Joystick Button Latching.vi

How can I do easier for the driver by making it 2 buttons. For example making one increment and the other one decrement. Lets assume that we have 7 positions:

Position1: to take the tube from the ground
Position2: 30 inches
Pos3: 38 inches
Pos4: 67 inches
Pos5: 75 inches
Pos6: 104 inches
Pos7: 112 inches

Let button increment be Button 2 on Joystick 2 and
Let button decrement be Button 3 on Joystick.

What I want is when I push button 2 if the lifting mechanism in
Pos (x-1) I want it to heightened to Pos (x).

And for the button 3 if the lifting mechanism in Pos (x) I want it to lowened to Pos (x-1).

Those position thing is just an example and what I am asking for is how to use one button repetitively ?

Thanks in advance!!


What does this symbol mean and where can I find it?

That is a Feedback Node.
You’ll find it on the Programming->Structures palette
The icon on the palette is just the arrow, but the whole thing shows up when you paste it onto the block diagram.[/quote]

So now if I wanted to use that button toggle action example on a solenoid how would I set that up? or if you know an example.vi that would be great.

Assuming you use the double solenoid that came in the 2010 or 2011 Kit of Parts, you’d combine the Double Solenoid Example with the Button Toggle example.

Essentially, you need to put a Solenoid Set into each of the Button Toggle Cases

  • Do One Thing (Set the solenoid to Forward)
    *]Do The Other thing (Set the solenoid to Reverse)

Well that makes sense haha thanks for all the help Mark.