Hacking an old Gamepad for Joysticks

My friend had a broken gamepad that had lots of buttons and of course two joysticks on it, and i had a feeling that the problem must lie somewhere in the PCB or loose solders or the wire might have snapped or the USB connector might have some problems.

???????????????????????????????

Let us first see what joysticks actually are…..THIS link will tell you what are they made up of. THIS will tell you the various programming aspects and technicalities.

Now once i opened the game pad i was confused. Which was the Vcc ,which was the Ground and which one was to be the “output” that arduino will read. And most importantly where were they. The situation got even more complex when i saw that there were two push buttons too .The actual position of the potentiometer pins on circuit board was easy to guess. On close inspection Vcc and GND were already mentioned , so i just applied 5v across them and measured the voltage across the terminals.

???????????????????????????????

This told me the position of the terminals and the output too. So the terminals were at the ends and the output in the middle as anticipated. Now all you have to do is to solder wires to GND , Vcc and the four outputs. But i didn’t realize this at that time !!. I had seen that there was a row of 5 wires and below it a row of 4 wires and in my mind only that was running that i had to find which row has the outputs(i was watching HOUSE M.D, that episode in which Foreman gets an infection supposedly from the cop, this was another reason why the idea didn’t strike me!!). You can easily guess which row !! but i needed a proof. I did a simple thing, i put my multimeter in the continuity mode and did a hit and trial by connecting the middle solder of the actual positions of the potentiometers and the solder points of the rows of wires. And in no time i knew which one would contain the output of which joystick and also along what axis.

This is how it looked in its raw form –

pin details

After removing the screws and soldering jumper wires it finally looked like this –

DSC01936

After all the soldering it was time to check if the joysticks were working properly. I wrote a program that read the inputs from the potentiometers and sent them as an array of 2 elements where the first element was the input from the first joystick and second element had the input from the second joystick.(i sent just the readings along one axis of both the joysticks.) the RX side read the payload and gave a PWM signal to drive two LEDs so that their brightness was controlled by the movement of joystick.

The TX code is….


#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(9,10);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
int red,blue;
int msg[2];
void setup() {
  Serial.begin(57600);
  printf_begin();
  radio.begin();
  radio.setRetries(15,15);
  radio.openWritingPipe(pipes[0]);
  radio.startListening();
  radio.printDetails();
  // put your setup code here, to run once:

}

void loop() {
  red = analogRead(A2)/4;
  blue = analogRead(A0)/4;
  msg[0] = red;
  msg[1] = blue;
  printf(" red reading = %d",msg[0]);
  printf(" blue reading = %d\n",msg[1]);
  radio.stopListening();
  if(radio.write(msg,sizeof(msg)))
  {
    printf("\nsent successfully!!\n");
  }
  else
    printf("\nfailed to send...");
  // put your main code here, to run repeatedly:

}

The rx program is…..

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(9,10);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
int msg[2];
const int ledRed = 3,ledBlue = 6;
void setup() {
  pinMode(ledRed,OUTPUT);
  pinMode(ledBlue,OUTPUT);  
  Serial.begin(57600);
  printf_begin();
  radio.begin();
  radio.setRetries(15,15);
  radio.openReadingPipe(1,pipes[0]);
  radio.startListening();
  radio.printDetails();
  // put your setup code here, to run once:

}

void loop() {
  if(radio.available())
  {
    bool done = false;
    while(!done)
    {
      done = radio.read(msg,sizeof(msg));
      if(done)
      {printf("read successfully !! \n");}
    }
   analogWrite(ledRed,msg[0]);
   analogWrite(ledBlue,msg[1]);
  }
  // put your main code here, to run repeatedly:

}
Advertisements

About Shantam Raj

Currently I am a final year B.Tech undergraduate majoring in “Electronics and Communication Engineering” from IIT Guwahati. I am passionate about electronics and robotics. Apart from that I love writing, visit https://medium.com/@shantam_raj for some of my works. I am a die hard soccer fan. I also love to play badminton. I am a hardware hacking enthusiast and a tinkerer !!.
This entry was posted in Arduino, DIY and tagged , , , , . Bookmark the permalink.

Leave a 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s