top of page

PS2 Joystick Test

Updated: Sep 6, 2020

Understanding the basics of joystick allows us to utilize joystick to control various output devices such as DC Motor, Servo, LED and a lot other devices


PS2 + Arduino

Simple connection as shown above can be used to test and understand the working fundamentals of a PS 2 Joystick. We will be talking more about the connection in the latter part of this article.

 

Joystick Feature

For a start, let's try to understand the Joystick PINS.

PS 2 JoyStick

As you can see, there are 5 pins on the Joystick. Let's list down the below pins and it's functions.



"VRX" and "VRX" are the pins used to detect changes and elevation in X and Y axis when the joystick is moved. So, connection to these pins need to be done according to your need.


For instance, if you only need to detect Y-axis movement, then only connect your controller to "VRY" and vice versa. You can also use a single joystick to detect movement in both axis, X and Y.

 

Circuit Setup


JoyStick Connection to Arduino

The connection that you have may differ based on the joystick pins arrangement that you have. However, the simple idea should always be as below :


Arduino GND = JoyStick GND

Arduino VCC = Joystick VCC

Arduino A4 = Joystick VER or VRY

Arduino A5 = Joystick HOR or VRX


Coding

Simply use the below code and upload it into Arduino Board and then move the joystick around to see the fluctuation of values in Serial Monitor

 

int x_key = A5; //detect changes from Analog5

int y_key = A4; //detect changes from Analog4

int x_pos;

int y_pos;


void setup() {

// put your setup code here, to run once:

Serial.begin (9600);

pinMode (x_key, INPUT);

pinMode (y_key, INPUT);

}


void loop() {

// put your main code here, to run repeatedly:

int x_pos = analogRead (x_key);

int y_pos = analogRead (y_key);

Serial.print("X axis : ");

Serial.println(x_pos);

Serial.print("Y axis : ");

Serial.println(y_pos);

}

 

Video Tutorial


Check out my video tutorial for more detailed explanation :




Comentários


bottom of page