Hey everybody,
I was just hoping somebody could help me out with some programming things. None of the students have taken to programming (they’re a first year team as well) and my limited experience with it has proven insufficient.
We would like to add a third joystick into our program. On this joystick, we plan to only use the buttons. We want a button to run our shooter motor at full speed when it’s pressed, and to stop running when the button is released. We would also like a button for running our pick up motor full speed, and for the motor to stop when the button is released. Lastly, we would like to have two buttons to move our motor driven ramp mechanism forwards and backwards in the same fashion).
Any help would be greatly appreciated. Thank you.
As far as using another joystick in the code, it is as simple as repeating the process you used with the first two joysticks (Open, SetRefNum in Begin.vi, getRefNum in Teleop.vi, getRefNum and Close in Finish.vi)
In order to get the button values, use the Joystick Get vi. One of the outputs is a cluster of booleans labeled buttons. In order to actually use the data inside the cluster, go to Programming->Cluster,Class->Unbundle By Name.vi.
To set the motors, you must Open them and set their refnum in Begin and the get the refnum in Teleop, similar to the joystick. to set speed, go to WPI Robotics -> Actuators -> Motor Control -> Set Speed vi. Passing the boolean values from the buttons is done by transferring the true/false boolean to a 1/0 integer value. There is a vi to do this in the Programming -> Boolean Pallette. In order to make the motors run in the correct direction, you may have to negate one or more of the values using the Negate vi found in Programming -> Numeric. If the motors run faster too fast for what you need them to do, you may wish to scale them by multiplying the integer value by a number less than 1 (.5 will run at 50% power, .75 at 75%, etc.). As a note, this method will cause the motors to run at the set speed as long as the button is pressed and to not move otherwise.
Hope this helps!