View Single Post
  #2   Spotlight this post!  
Unread 23-01-2013, 21:42
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Toggling Buttons in Java

Quote:
Originally Posted by JCHS View Post
Hi, I'm new to programming in Java and I'm trying to learn how to control our robot. We are using the command based robot in Netbeans. Using examples and threads I got the 4 motor drive to work. My next challenge is to toggle our shooter on and off. We are using two motors controlled by Talons, one in PWM 5 and the other in PWM 6.

So far I have managed to get the button to turn the motors on when held, and off when let go. Then when I tried to toggle it, all i could manage was on. It wouldn't turn off. I have looked through threads and online at www.github.com, but still don't understand how to toggle the button. I just don't know what to put in the OI, in the command, and in the subsystem.

Any help would be appreciated. Thanks for your time.

If you need more information or my code i'm more than happy to post it but wanted to get this thread out as soon as possible.
I had this problem yesturday

make sure the method your using is .whileHeld();

turn off your motors in the interrupted() method of your command. the interrupted method will automatically run when teh button is released as long as whileHeld() is the command being used
Reply With Quote