Code Not Working Properly

So I’m having a hard time trying to figure out why my code isnt working properly.I want that when I press button 3 on joystick 1 it would give a output of 0.75 to the motor connected to pwm 3. It works properly but I thought I programmed it that when u press again(Button 3) it would turn off. So pretty much I want Button 3 to be like a motor on and off switch. Im really stuck and cant figure out why the shooter wont turn off when I press it again. Thxs any help would be greatly appreciated :slight_smile:

Shooter.vi (32.4 KB)


Shooter.vi (32.4 KB)

I looked at the VI and have a few suggestions.

You are using a feedback node which can keep track of previous values, but you aren’t really using the value stored in it.

The attached image shows how to use the feedback node to update the motor when the button changes and the new state determines what the motor does. It may be even better to select the value and update the motor in only one place.

Greg McKaskle

Clipboard 1.png


Clipboard 1.png

Can you upload a picture of the whole code. Sort of confused of where exactly I place the feedback node

The code takes the button value and compares to the last value, the value delayed by the feedback node. When different the button was either just pressed, or just released. The you can distinguish by using selects, cases, or an AND node with the current value. Once you know whether it just went down or came up, update the motor to the appropriate value, as your code already was doing.

By the way, the bottom * portion of the feedback node is for initialization. My code left it blank which may not be appropriate. The better choice is probably to wire the button to both the input of the node and the * initializer.

Greg McKaskle