GK-AMO-AJOY geeekus PS2 Analog 2 Axis Joystick Module with Button for Arduino

Price:
US$4.50
GK-AMO-AJOY
In stock
+
Add to wish list

The geeekus Joystick Module is widely used in gaming, robot control, drone control, arduino projects, micro:bit and raspberry pi projects.

This 2 Axis Joystick Module with Button outputs two analog (potentiometer) and one digital (microswitch) outputs. The joystick is especially used with Arduino and comes with headers to easily connect to a breadboard for rapid protoyping.. Use it to add directional control to your microcontroller.
The joystick is analog so it can measure not only the direction, but also how far you press in a particular direction.If you press the joystick straight down you can activate a push button. This can be useful, for example, to confirm a choice in a menu. If you look to the side of the joystick you can see the switch.
The joystick module has 3 signal terminal pins, which simulate a three-dimensional space. The pins of the joystick module are GND, VCC, and signal terminals (B, X, Y). The signal terminals X and Y simulate the X-axis and Y-axis of the space. When controlling, the X and Y signal terminals of the module are connected to the analog port of the microcontroller. The signal terminal B simulates the Z axis of the space, it is generally connected to the digital port and used as a button.

Specifications:
Supply Voltage: 3.3V to 5V
Interface: Analog x2, Digital x1
Size: 40*28mm
Weight: 12g

 

Sample Code for image above

Connect the Y pin of module to Analog A1 of UNO board, connect the X pin to Analog A0, B pin to Digital 3; Connect negative pin to GND port, positive pin to 5V port.

int JoyStick_X = 0; //x
int JoyStick_Y = 1; //y
int JoyStick_Z = 3; //key
  void setup() {
  pinMode(JoyStick_Z, INPUT);   Serial.begin(9600); // 9600 bps
}
void loop() {
  int x,y,z;
  x=analogRead(JoyStick_X);
  y=analogRead(JoyStick_Y);
  z=digitalRead(JoyStick_Z);
  Serial.print(x ,DEC);
  Serial.print(",");
  Serial.print(y ,DEC);
  Serial.print(",");
  Serial.println(z ,DEC);
  delay(100);
}

 

Once you upload the code, open the serial monitor on Arduino software, and set the baud rate as 9600 and you will see the value shown below. If you push the joystick downward/upward/leftward/rightward, the data in the values below will change.

Notice for California Residents: Warning symbolWARNING: Cancer and Reproductive Harm - www.P65Warnings.ca.gov