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.