arduino joystick wiring

I recently purchased an arduino compatible joystick, but i'm not sure how to wire it. I presume it needs an analog input and ground but there are 5 pins in total. Can anyone suggest what I need to plug into each of the pins? This is where I bought it from:

The pins are labelled: GND, +5U, VRx, VRy, SW.

Any help would be greatly appreciated.

From the sellers website:


define JOYS_VRX_DIO A0 /* Selects the input pin for the joysticks X-Axis */

define JOYS_VRY_DIO A1 /* Selects the input pin for the joysticks Y-Axis */

define JOYS_SW_DIO 2 /* Selects the input pin for the joysticks push button */

/* Initialises serial and DIO / void setup() { / Sets up the serial port for displaying the status of the sensor */ Serial.begin(9600);

/* Configures the DIO pin that the joysticks push button will be connected to. As it has no pull-up we will need to enable the Arduino's internal pull-up */ pinMode(JOYS_SW_DIO, INPUT); digitalWrite(JOYS_SW_DIO, HIGH); // turns on pull-up resistors }

/* Main program loop / void loop() { / Reads the current position of the joysticks X & Y axis via the analogue pins */ Serial.print("X axis: "); Serial.print(analogRead(JOYS_VRX_DIO)); Serial.print(" Y axis: "); Serial.print(analogRead(JOYS_VRY_DIO));

/* Reads the state of the push button and if pressed, outputs the state to the serial port */ if (!digitalRead(JOYS_SW_DIO)) { Serial.println(" Button pressed !"); }else { Serial.println(); } }

So VRx and VRy are connected to analog pins, SW is connected to a digital pin and GND is connected to ground. Is 5U+ connected to power and would I need to put a resistor in the circuit?

X and Y are connected to two analog pins +5v is connected to 5v pin on the arduino, it feeds the X Y input to read from. Something like all the way one direction 4.5v center 2v all the way the other direction 0.5v. The SW to a digital pin and ground to ground. In software they are using the internal pull up so when you push the button you are giving it a easier (less resistance) path to ground, so no external pull up resistor is needed.