The idea behind this project was originally to build a console out of things that I could find around my house. The main 2 components being an old xbox 360 controller and an old android tablet
However as the project progressed, it became apparent that it was going to become a lot more complicated
Original design was to extend the controller for the console so it would fit on either side of the board screen
(pictured to the left)
After attempting the original design multiple times and not having successful results I opted to try a new design
Based on some designs I found online - I put together 2 doubled sided PCBs for the left and right side - which i would then wire together
The PCB took quite a few tries because it was supposed to be double sided and getting things to line up on both sides proved to be quite the challenge
To help the carbon from rusting I applied a home-made solder mask
But after multiple failures, with the help of Dr. Sorber, we decided it was best to just use a protyping board and solder the connections that way
I then 3D models the controller to fit tablet. Taking measurements of the tablet, the buttons I was using, the PCB, and the joycons. It was extremely important that everything fit just right
I models the top faces of the controller to come off so that I could mount the electronics easily on the inside
Image credit: iFixit
the backside of the top faces were modeled after an Xbox 360 controller
the first 3D printed prototype
making sure the protype board will fit before soldering everything down
Checking D-pad and joystick sizes
//the image to right was created to give me a brief idea of the destination of each pin as well as which side the connection is soldered
//for this project I used Arduino's built in Gamepad library
//this script is heavily based on one I found online and is not a great example of my own work. For more programs see projects under "why computer science"
//credit to Arnov Sharma
include <Gamepad.h>
int rightXcenter = 500;
int rightYcenter = 500;
int leftXcenter = 500;
int leftYcenter = 500;
double multiplierRX = 0.254; //127 / 500 : 127 is a more standard number used for calibrating joysticks
double multiplierRY = 0.254;
double multiplierLX = 0.254;
double multiplierLY = 0.254;
Gamepad gp; // declares the gamepad object
void setup() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(14, INPUT_PULLUP); //UPPER RIGHT
pinMode(15, INPUT_PULLUP); //UPPER LEFT
pinMode(1, INPUT_PULLUP); //LEFTBUTTON
pinMode(0, INPUT_PULLUP); //RIGHTBUTTON
pinMode(4, INPUT_PULLUP); //UP
pinMode(5, INPUT_PULLUP); //DOWN
pinMode(6, INPUT_PULLUP); //LEFT
pinMode(7, INPUT_PULLUP); //RIGHT
pinMode(8, INPUT_PULLUP); //X
pinMode(9, INPUT_PULLUP); //Y
pinMode(10, INPUT_PULLUP); //A
pinMode(16, INPUT_PULLUP); //B
calibration();
}
void loop() {
int lx, ly, rx, ry;
lx = analogRead(A3);
ly = analogRead(A2);
rx = analogRead(A1);
ry = analogRead(A0);
//we need to convert a 0-1000 to (-127) - 127
//1000 is the standard max range for this library
lx = floor((lx - leftXcenter) * multiplierLX);
ly = floor((ly - leftYcenter) * multiplierLY);
rx = floor((rx - rightXcenter) * multiplierRX);
ry = floor((ry - rightYcenter) * multiplierRY);
if(lx > 127) lx = 127;
if(ly > 127) ly = 127;
if(rx > 127) rx = 127;
if(ry > 127) ry = 127;
gp.setLeftXaxis(lx);
gp.setRightXaxis(rx);
gp.setLeftYaxis(ly);
gp.setRightYaxis(ry);
//declare our buttons as ints to get their input number
int UPLEFT, UPRIGHT, UP, DOWN, LEFT, RIGHT, RIGHTBUTTON, LEFTBUTTON, X, Y, A, B;
UPLEFT = digitalRead(14);
UPRIGHT = digitalRead(15);
RIGHTBUTTON = digitalRead(0);
LEFTBUTTON = digitalRead(1);
UP = digitalRead(4);
DOWN = digitalRead(5);
LEFT = digitalRead(6);
RIGHT = digitalRead(7);
X = digitalRead(8);
Y = digitalRead(9);
A = digitalRead(10);
B = digitalRead(16);
//handles button inputs
if(UPLEFT == LOW)
gp.setButtonState(0, true);
else
gp.setButtonState(0, false);
if(UPRIGHT == LOW)
gp.setButtonState(1, true);
else
gp.setButtonState(1, false);
if(UP == LOW)
gp.setButtonState(2, true);
else
gp.setButtonState(2, false);
if(DOWN == LOW)
gp.setButtonState(3, true);
else
gp.setButtonState(3, false);
if(LEFT == LOW)
gp.setButtonState(4, true);
else
gp.setButtonState(4, false);
if(RIGHT == LOW)
gp.setButtonState(5, true);
else
gp.setButtonState(5, false);
if(RIGHTBUTTON == LOW)
gp.setButtonState(6, true);
else
gp.setButtonState(6, false);
if(LEFTBUTTON == LOW)
gp.setButtonState(7, true);
else
gp.setButtonState(7, false);
if(X == LOW)
gp.setButtonState(8, true);
else
gp.setButtonState(8, false);
if(Y == LOW)
gp.setButtonState(9, true);
else
gp.setButtonState(9, false);
if(A == LOW)
gp.setButtonState(10, true);
else
gp.setButtonState(10, false);
if(B == LOW)
gp.setButtonState(11, true);
else
gp.setButtonState(11, false);
delay(20);
}
//calibration
//essentially checks if any of the inputs have changed at all times
void calibration()
{
int lx, ly, rx, ry;
int i = 0;
while(i < 13)
{
lx = analogRead(A3);
ly = analogRead(A2);
rx = analogRead(A1);
ry = analogRead(A0);
bool validLX = lx > (leftXcenter - 100) && lx < (leftXcenter + 100);
bool validLY = ly > (leftYcenter - 100) && ly < (leftYcenter + 100);
bool validRX = rx > (rightXcenter - 100) && rx < (rightXcenter + 100);
bool validRY = ry > (rightYcenter - 100) && ry < (rightYcenter + 100);
if(validLX && validLY && validRX && validRY)
{
i++;
}
else i = 0;
delay(20);
}
leftXcenter = lx;
leftYcenter = ly;
rightXcenter = rx;
rightYcenter = ry;
multiplierLX = (double)127 / (double)lx;
multiplierLY = (double)127 / (double)ly;
multiplierRX = (double)127 / (double)rx;
multiplierRY = (double)127 / (double)ry;
}