Skip to content

Interfacing Wireless PS2 Controller with Arduino

 

Hi, in this tutorial we’ll try to interface a PS2 wireless controller with Arduino UNO board, it is very interesting since all the controller’s buttons would be inputs for the Arduino board and not only that but also wireless, using 2.4GHz Radio Frequency communication protocol, which can be very useful to control robots, vehicles, servos…

sony-playstation-2-dualshock-ps2-wireless-remote-without-box-500x500

I bought this controller with A servo dedicated board for 30 USD, you can get the controller/Receiver much cheaper, but don’t forget that these cheap things have some problems (you can see it in the video), the sensitivity is not that good comparing it with the original controller, but that’s not a big deal for the moment.

You can learn a lot about this controller visiting this website: billporter.info

Since here we don’t talk too much lets get to the wiring.

Wiring:

Considering from which side you are observing this is the order I followed, the pins #3 and #8 don’t have a connector at all, also we’re not using the pin #9.

1

This is my wiring sorry it’s not very esthetic.

2

Wiring with the usual LCD i2c screen, I used with the code I made.

 

Libraries and codes:

-LCD i2c Library

-PS2X Library

-Code using LCD

The code I’ve used in the tutorial: The first one you’ll find it in the library, it shows different functions you can use such as reading the analog stick values, detect if a button is pressed, released or being held…., also it detects which type of controller you are using or showing you an error if there is one.

The second code just takes few functions and shows the value or the buttons that are being pressed on the screen, here I only associated printing on lcd screen for every function, but for you, you can control servos, dc motors, leds… overall it’s just an example for the tutorial.

Hope you like it, and if you have any problem you can contact me.

Yassine View All

Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.

10 thoughts on “Interfacing Wireless PS2 Controller with Arduino Leave a comment

  1. brother, I want to do a counter using some axis of the stick to control servos later,
    the problem is that I want to use the value (controlps.Analog (PSS_LY), DEC); and use conditional “if” to increase or decrease said counter.
    when doing this, the “++ or –” operation does not respond, but the function does recognize the real-time position of the stick,
    can you support me to determine the fault ?.
    —————————————————————–

    #include //

    PS2X controlps; // create PS2 Controller Class

    int contadorservo;//—–>counter variable

    void setup() {

    controlps.config_gamepad(13,11,10,12, false, false); // GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
    Serial.begin(9600);
    }

    void loop() {
    byte vibrate = 0;
    int lectura=(controlps.Analog(PSS_LY), DEC);
    controlps.read_gamepad(false, vibrate);

    if(lectura==0) {contadorservo=contadorservo++;} //condicional only for fast test
    if(lectura==128){contadorservo=contadorservo;}
    if(lectura==255){contadorservo=contadorservo–;}

    Serial.print(contadorservo); //—–> print the data
    Serial.print(” “);
    Serial.println(controlps.Analog(PSS_LY), DEC);
    }

    —————————————
    Best regards and grace for the support

    Like

  2. Hi I’ll take a look to this, do you want to control a servo using the stick? because I have done a project where I control dual axis camera tilt with a ps2x stick.

    Like

  3. Try this writing

    if(lectura==0)
    contadorservo++;
    if(lectura==255)
    contadorservo–-;

    Try not to copy/paste this directly it may result in some errors like “stray ‘\342’ in program” and it won’t compile.

    Like

  4. brother could you make a post with the code with the project that you tell me, I would like to have a reference with a functional project, the example of arduino has several functions running and on the internet I only find projects using buttons and no stick

    thank you for your support my email is marckoe93@hotmail.com
    Regards

    Like

Leave a Reply to YassineCancel Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: