Custom Made Subway Surfers Controller
by Piyush_ROBOTICS in Circuits > Arduino
1079 Views, 6 Favorites, 0 Comments
Custom Made Subway Surfers Controller
Hi, My name is Piyush!
In this Instructable, I am going to show you a Game Controller I Made for Subway Surfers. It is Custom Made and can be taken and used Anywhere. It is Very Easy To Assemble by Hot-Gluing it.
When I saw this "Puzzles and Games Contest", I Got the Idea of making a Controller for a Game using new libraries and making it for the Game Subway Surfers is the best, because I could use my Imaginary Charectar as the Input where my Index and Middle finger are up and I use it as legs of my character and make it Run Across Walls.
Supplies
Tools:
- Hot Glue Gun
- Soldering Iron
- 3D Printer
- Wire Cutter
Items:
- Wires
- 3D Printed Pieces
- 3 Potentiometers
- 2 Tactile Switches
- Arduino Pro Micro
- Phone Charger to USB Type B (In my phone I have USB C, so In my Case, it would be USB C to USB B)
Software:
- Subway Surfers Installed on Phone
- Arduino on Laptop
*USE EXPLOSION MODLE FOR REFERENCE*
Building the Switch Mechanism
We will start by Building the Controller, then the Software Part, and then the Testing. For every Instruction, there is a Picture for reference to Help!
1. Take the Side Switch 3D Printed Piece and glue it to the Switch so it aligns with the notch.
2. Next, Mirror the Same thing so the Switch is facing Upside-Down and turned 90° as shown in the Picture.
3. And to Case Everything, put the Second 3D Printed Piece on the Other Side.
Making Connections Part 1
1. Take 2 of your Potentiometers and make sure the Knob is centred as shown in the Picture.
2. Attact Each Potentiometer at Each Side; Make sure the Orientation is correct.
3. Use the Schematic Provided for the Next Few Steps, Connect Everything Except the 3rd Potentiometer("Main Base")
Adding Yaw Axis and Making Connections Part 2
1. Take the 3D Printed Piece which looks like a Flipped Table and Mount it on the Potentiometers and Glue it. Make Sure that the body can still Rotate.
2. Take your 3rd Potentiometer and fold the pins as Shown and Turn the Knob as much as possible Clockwise.
3. Fix the 3rd Potentiometer under the "Flipped Table" Without Turning the Knob as shown in the next 2 Pictures Above.
Final Connections and Complete Mechanical Part
1. Stick the Potentiometer like Shown in Picture 1.
2. Complete the Connections Using the Schematic and Turn The Pad so It's aligned.
There You Go! Your Subway Surfers Controller is Done!
Software
If You want to know Everything in Detail about the Library (Recommended)
STEPS:
1. First, Go to the link below to go to GitHub and then click on Code>Download Zip. Once downloaded, go to the Arduino IDE and click Sketch > Include Library > Add .zip Library. In the file dialogue windows that opens, locate your downloaded ZIP file.GitHub Link:https://github.com/dmadison/ArduinoXInput
2. Start Arduino and open the Preferences window. Paste the Link into the Additional Board Manager URLs field. If another Link filled in the field, You can add a comma before Pasting the new link to separate them and Press save before restarting the application.
3. Go to Board>Boards Manager and Search for Xinput and Install the Latest Version. When done choose your Arduino Pro micro from the “Xinput AVR Boards” in the Tools>Boards menu.
Code Instructions (IMPORTANT) -Uploading Code for the Second time:
After uploading a code for the First Time and you want to upload the code again to Your Microcontroller,You need to Follow a Few steps. First Press the Upload Button. Second, After a few moments, you will see a message “Waiting for upload port…” When you see this message, you need to Press/Connect the RST Pin (Reset) to the GND (Ground) for a second then Release/Disconnect the Pin, If done correctly, you will see the code is uploading (Red Colour Text). If you see yourself stuck on the uploading page After “Waiting for upload port…”,Connect the RST Pin (Reset) to the GND (Ground) for a second then Release/Disconnect the pin again And the Code Should Be Uploaded.
Code:
#include <XInput.h>
#define Keymap 2 //change 1 or 2 to see what settings you like (changes output givin to phone; TRY BOTH) 1 is easier to use while 2 makes more sense
int yaw, roll, up, down;
int skateboard;
void setup() {
// put your setup code here, to run once:
pinMode(10, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
Serial.begin(9600);
XInput.begin();
}
void loop() {
// put your main code here, to run repeatedly:
yaw = analogRead(A0);
roll = analogRead(A2);
up = !digitalRead(16);
down = !digitalRead(10);
Serial.print("Yaw:");
Serial.print(yaw);
Serial.print(" Roll:");
Serial.print(roll);
Serial.print(" Up:");
Serial.print(up);
Serial.print(" Down:");
Serial.print(down);
if (yaw < 820) {
Serial.print(" skateboard:Not Activated");
skateboard = 0;
} else if (yaw > 820 && skateboard == 0) {
Serial.print(" skateboard:Activated");
skateboard = 1;
XInput.press(BUTTON_A);
delay(70);
XInput.release(BUTTON_A);
delay(100);
XInput.press(BUTTON_A);
delay(70);
XInput.release(BUTTON_A);
} else {
Serial.print(" ");
}
if (roll < 593 && roll > 507) {
Serial.print(" Swipe:Stay");
} else if (roll > 593) {
Serial.print(" Swipe:Left");
XInput.setDpad(false, false, true, false);
delay(800);
XInput.setDpad(false, false, false, false);
delay(10);
} else if (roll < 507) {
Serial.print(" Swipe:Right");
XInput.setDpad(false, false, false, true);
delay(800);
XInput.setDpad(false, false, false, false);
delay(10);
}
if (Keymap == 1) {
if (down == 0) {
XInput.setDpad(true, false, false, false);
delay(800);
XInput.setDpad(false, false, false, false);
}
if (up == 1) {
XInput.setDpad(false, true, false, false);
delay(800);
XInput.setDpad(false, false, false, false);
}
}else if (Keymap == 2) {
if (up == 1) {
XInput.setDpad(true, false, false, false);
delay(800);
XInput.setDpad(false, false, false, false);
}
if (down == 1) {
XInput.setDpad(false, true, false, false);
delay(800);
XInput.setDpad(false, false, false, false);
}
}
Serial.println();
}
Downloads
Download and Use "Octopus"
1. Connect The Arduino Pro Micro with Your Phone.
2. Install Subway Surfers on your Phone.
3. Next, Go to the Play Store and download "Octopus" as shown in the image. Then open the app, click on Add Games and choose Subway Surfers as shown. Finally, Click the app and Keep on pressing Skip until the app Opens.
4. Locate the Octopus Icon, Click on it and Then Click on the + icon Next. Drag and Drop The D-Pad and After that the Key Button as Shown in the Picture Above. Once You Place the Key, it will be Asking For a Input,Take the Subway Surfers Controller and Turn the Pad Clockwise And if The Controller is Working Properly, a Capitalised "A" Should Appear.
5. Turn The Pad Back So it's Aligned.
Testing the Controller
In the First Part of the Video, It Shows the Instructions for the Previous Step, Rest is The Testing.
Hope You Had A Fun Time Building With Me!