Checking Rookie Programmer's code to switch between motors

Unfortunately, the first time I attempted to use a case structure to run the robot, it didn’t work. We didn’t have much time to program

Our team needs to be able to switch motor controls and I was wondering if this is the correct way of doing the code. We need to be able to press a button (only once) and it would switch the motor control. Press it once more to switch back to the original motor control.

Thank you so much. :slight_smile: :smiley: :o

This is in telop VI

Double Check.vi (11.3 KB)


Double Check.vi (11.3 KB)

The posted code will activate the alternate function while the button is held. It will not toggle when the button is pressed.

For a toggle check out Team 358’s Labview Examples page. There is an example there called “Button Toggle Action”.

There is also an example provided with Labview. Click “Find FRC Examples” on the splash screen, look under “Joystick” and find “Joystick Button Latching”

While there are certainly ways to make a single button push switch from one mode to another, the easiest thing (if I’m interpreting your code correctly) would be to just hold down Button 11. Otherwise, you’ll have to add a shift register and/or global variable to keep track of when you press the button. You’d only want to change states when you just pressed the button, meaning a) the last time through, the button wasn’t pressed, AND b) this time, the button is pressed. So you’d have to store what the button was the last time, recall it, compare it to what the button is this time, and only make a change when Last Time = False and This Time = True.

It’s going to be a much simpler code to just hold the button down. Our joystick 1 controls the arcade drive of the robot while 2 other joystick will be used for the arms. It’s good for the CRIO so that it doesn’t overload.

Thank you for your Gracious Professionalism:) :smiley: