View Single Post
  #2   Spotlight this post!  
Unread 13-02-2010, 13:50
EthanMiller EthanMiller is offline
Lead Programmer
AKA: Socks
FTC #4356 (The Zip Ties)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Clayton, NY
Posts: 121
EthanMiller has a spectacular aura aboutEthanMiller has a spectacular aura aboutEthanMiller has a spectacular aura about
Re: Toggle through button?

Depending on what language you're using, and assuming that we're using Java and joystick button 2, the code would look something like:

Code:
if joystick.getButton(2) == true && number < 2 {
     number++
} else if joystick.getButton(2) == true && number == 2 {
     number = 0
}
Note - this code is untested. Be sure to declare "number" and set it to 0 earlier in the program.

Also, this code will use values 0, 1, and 2, rotating each time the button is pressed.
__________________
When all else fails, read the manual.

FRC 1713 K Island Gears 2009, 2010 (Not 2011 due to budget, hopefully 2012!) - Fingerlakes Regional

FTC 4356 The Zip Ties 2010-2011 Season - NNYRC (2010 9th seed).