|
Re: Adding third joystick and button controls
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!
|