Programming a joystick to give certain colours

which function do i use to return the value that was last used if you have more than 1 values.

i have a program whereby you turn a joystick to 5 different directions to give you certain colors.
Now my question is, how to do i program it to show me the color that was previously selected