Easy Basics: Project 058a Wireless PS2 controller

of Lex C. in UNO

Basics: Project 058a

Project name: Wireless PS2 controller

Tags: Arduino Uno, Arduino, PS2 controller, PlayStation 2 controller, 2.4G Wireless game gamepad joystick for PS2 controller, Sony playstation 2 console, dualshock gaming joypad for PS 2 play station, Wireless PS2 controller

Attachments: library1, sketch1

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Arduino Uno R3 (you can also use the other version of Arduino)

2. Wireless PS2 controller  1pc

3.Arduino IDE ( you can download it from here  )

4.Jumper cables M-M 

5. Breadboard (any size) 1 pc

6. Resistor 4 pcs (1KOhm)


We will learn how to connect wireless PS2 controller to Arduino board and use it.

Understanding the wireless PS2 controller

The PS2 wireless controller is a standard controller for the PlayStation 2 and is identical to the original DualShock controller for the PlayStation console. It features twelve analog (pressure-sensitive) buttons ( Χ, O, Π, Δ, L1, R1, L2, R2, Up, Down, Left and Right), five digital button (L3, R3 Start, Select and the analog mode button) and two analog sticks. The controller also features two vibration motors, the left one being larger and more powerful than the one on the right. It is powered by two AAA batteries. It communicates with the console using 2.4 GHz RF protocol.

PS2 wireless controller communicates with Arduino using a protocol that is basically SPI. The play station sends a byte at the same time as it receives one (full duplex) via serial communication. There’s a clock (SCK) to synchronize bits of data across two channels: DATA and CMD. Additionally, there’s a “Attention” (CS) channel which tells the slave whether or not it is “active” and should listen to data bits coming across the CMD channel, or send data bits across the DATA channel (Reasonably, only one slave device should be active at a time) . The PlayStation 2 actually uses this plus an additional line that is not specifically part of the SPI protocol – an “Acknowledge” (ACK) line.

The clock is held high until a byte is to be sent. It then drops low (active low) to start 8 cycles during which data is simultaneously sent and received. The logic level on the data lines is changed by the transmitting device on the falling edge of clock. This is then read by the receiving device on the rising edge allowing time for the signal to settle. After each Command is received from the controller, that controller needs to pull ACK low for at least one clock cycle. If a selected controller does not ACK the PS2 will assume that there is no controller present. LSBs (least significant bits) are transmitting first.

Key features:

• High-quality ABS material

• 2.4 GHz wireless reception technology, 8-meter range

• Digital/analog, two modes of operation, can be switched at any time, with mode prompt light

• 4-axis, 12 keys designed to meet the needs of game keys (digital mode: 2-axis 10 keys; analog mode: 4-axis 12 keys).

• A receiver, two interfaces.

• Needs to use two AAA (7) batteries (not included)


• Handle model: NJP215B

• Handle brand: Nygacn Nika

• Product weight 173.5 grams

• Working range: ≤8 meters

• Operating current: 12 mA

• Vibration current: 120 mA

• Standby current: 20 μA

• Dimensions: 15.7 x 9.3 x 6 cm

• Function keys: Arrow keys + 11 common keys + 2 rockers

• Battery: 2 AAA (7) batteries (not included)

• Packaging: High-frequency blister packaging

• Color: Black

Product includes:

• 1 x Wireless controller

• 1 x Receiver

Interface: For Sony PlayStation 2 host


  • To control a wheeled or tracked vehicle's motion.
  • To control a robotic arm.
  • To interact with a PC.
  • To control a pan and tilt camera mount.
  • DIY radio control system by using a bluetooth module, or radio module to transmit the commands from the Playstation 2 controller to another Arduino which is controlling the vehicle.
  • The pilot interface for an underwater drone.

Signals and connections of the PS2 controller

Don’t trust the color scheme on the wiring picture. It can vary! Instead, use a voltmeter and test continuity between pin positions in the connector and the bare wires. A few people report odd color schemes, and a few not realize what end of the connector they were looking at and got the wiring completely backwards. A quick check is to power up the controller, and pushing the ‘Analog’ button. Either the LED should have been on when it powered up, or it should light up when you press the button. If not, the controller isn’t getting power and you probably have the wiring reversed.

VDD- power supply +3.3VDC. Connected to Arduino board 3.3V pin.

GND - ground. Connected to Arduino board GND pin.

ACK - Acknowledge. Acknowledge signal from Controller to PS2. This normally high line drops low about 12us after each byte for half a clock cycle, but not after the last bit in a set. This is a open collector output and requires a pull-up resistor (1 to 10k, maybe more).

PS2 - NC. Not in use

CLK - SPI communication. SCK (Serial Clock) - The clock pulses which synchronize data transmission generated by the master

CS - (ATT) Attention - used to get the attention of the controller. This line must be pulled low before each group of bytes is sent / received, and then set high again afterwards. This pin consider as “Chip Select” or “Slave Select” line that is used to address different controllers on the same bus.Chip select input pin (“Low” enable). 

NC - Not in use

D0 - Command. PS2 > Controller. Master In Slave Out (MISO) - SPI communication. The Slave line for sending data to the master. 

DI - Data. Controller > PS2. Master Out/Slave In (MOSI). SPI communication. The Master line for sending data to the peripherals. 


Here we have interfaced the PS2 Wireless Controller with an Arduino. Upon each button press the Arduino receives the RF signal on the PS2 receiver and displays the it on the alphanumeric LCD module. We followed the standard PS2 protocol for realizing the communication algorithm, identical to the SPI protocol.

The PS2 receiver CLK line and ATT lines are held normally high. The  ATT operates like the Slave Select line under SPI. You pull it low to tell the controller you are talking to it and then send it back high once a communications cycle is complete. CMD is the data line to the controller and DATA is the data coming from the controller. Here in our project we are not using the acknowledge pin.

Step by Step instruction

The "blank" sketch won't work for "native USB" based Arduinos like the Leonardo, Micro, Zero, etc! Use the

Leo_passthru sketch instead!
  1. There are several options for connecting the controller to the Arduino: a) to cut the connector off and connect the wires into a row of terminal headers or directly solder them to some other plug or jumper cables; b) to retain the plug and find a suitable socket .
  2. Uncrew the PS2 receiver. Unsolder the male connector and solder 7 M-M jumper cables.
  3. Do wiring.
  4. Open Arduino IDE.
  5. Plug your Adruino Uno board into your PC and select the correct board and com port
  6. Verify and upload the sketch to your Adruino Uno
  7. Open the Serial Monitor at a baud rate of 9600.
  8. Power on the PS2 controller - set the power switch to ON position. Hold down the handle for PS2 button so that the RX light flashes into a light that has been connected successfully.
  9. Test the buttons. Results printed in Serial Monitor.


To use the library in an Arduino Sketch, it needs to be called using the following commands;


PS2X ps2x; 

In the setup part of the sketch the command to let the Arduino know how the controller is connected to it, looks like;

ps2x.config_gamepad(13,12,10,11, false, false);  

where the numbers are the Arduino's digital pins where the Playstation 2 Controller pins are connected as below;

gamepad(clock, command, attention, data, pressure sensitivity enabled, rumble enabled)

If you wanted to use the button pressure sensitivity feature, in the command line above you would set this to “true” and if you wanted the rumble motor available to provide feedback then you would set this to “true” too. For use of the rumble feature please look at the example sketch that comes with the PS2X library.

Once the controller is set up, the Arduino loops through the sketch continuously. Once per loop through, the Arduino needs to communicate with the controller to gather all input data. This is done with the following command.


Now we can read which control has been used. The labels used in the PS2X library are very logical. The diagram below shows each of the names for the buttons and sticks.

The buttons with the coloured shapes can also be referred to by the names PSB_TRIANGLE, PSB_CIRCLE, PSB_CROSS, and PSB_SQUARE.

To use the analogue pressure sensitivity on the keys the names are the same except for substituting “PSAB” for “PSB”. So to allow a pressure reading from the Green Triangle button the name would be PSAB_GREEN or PSAB_TRIANGLE.

The buttons can be pressed, pressed and held, or pressed with a varying pressure, so there are a number of methods that can be applied to the buttons and joystick. The methods are; Button Pressed, Button, and Analog. Here are some examples of how these are used.

ps2x.ButtonPressed(PSB_RED) is for a simple press of the red circle button.

ps2x.Button(PSB_PAD_DOWN) is for the down button on the pad being pressed and held.

ps2x.Analog(PSAB_CROSS) is the command for measuring the pressure applied to the “X” button, if pressure sensitivity has been enabled. As you can see the “PSAB” form of the name has been used for the button.

ps2x.Analog(PSS_RY) is the command to obtaining readings off the right analogue stick in the vertical direction.


We learnt how to connect the wireless PS2 controller to Arduino board and use it.


  • All libraries attached on the begining of the project description
  • PS2X_lib library. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read more about it here.


  • See attachments on the begining of this project

Other projects of Lex C.

Published at 26-02-2018
Viewed: 5741 times