I am a relatively new programmer on Team 1325, and one of my tasks is to write the code for our shooter. Currently in my code, when a button is pressed, the motors of the shooter turn on, at the speed of the axis of the joystick, and when the button is released, the motors stop. This works, but I would like to have some code that does the following;
When a button is pressed, the motors start, and the motors continue to run even if that button is released.
When another button is pressed stop the motors of the shooter.
I thought about using a while loop earlier to accomplish this but I read somewhere that while loops should not be used in the TeleOp section of the code. I also know that a feedback node could be used to accomplish what I want to do, but I am not sure where to start.
one button control a Case statement that sets the motor output in True to 1, but does absolutely nothing in the False case.
A second button do the same thing, but set the motor output to zero, but also does absolutely nothing in the False case.
You can tied the two case statements together to force an order in the event both buttons are pushed simultaneously, but it isn’t necessary in this particular application
A second cleaner way is to use a feedback node to remember the previous value and only change the value when one of the buttons is pushed.
I’ll sketch an example up. This fits into your existing scheme the easiest.
So you want to try something like this.http://team358.org/files/programming/ControlSystem2009-/LabVIEW/ButtonToggle.jpg
When you click the button you program it will turn on the motor. After you release the button it will continue running. After you click the same button again it will shut off the motor. Remember to place your the “Motor Get” and “Set Output”. Then just create a Constant depending how fast you want the motor to move when the button is clicked and in the false case you want to create a constant of 0.