Arduino Retro Game Controller
Greetings everyone and welcome back. Here's something fun.
The Arduino Retro Game Controller was built from scratch using a custom PCB and a couple of 3D-printed parts. The Arduino Micro, which has the Atmega32U microcontroller with HID, compatibility, is being used here to transform the microcontroller into a game controller.
The goal was to put together a game controller that would allow users to play Pokémon games using an emulator. Here, we chose an all-buttons controller that does not have an analog or thumbstick, but we have included two joysticks on the main PCB that will be used in the project's second revision.
Along with a few resistors that are connected in series with each button, the buttons are positioned on the top side of the board. In this case, all of the button data is being read using a single I/O pin.
Along with two 3D-printed handles that are connected to the left and right sides of the circuit, the Arduino Micro is positioned on the bottom side of the board.
When this controller is plugged into any device—Windows, Linux, or even a Raspberry Pi—it registers as a game controller; all the user has to do is map the keys and start using it.
Materials Required
These were the materials used in this project.
- Custom PCB (Provided by PCBWAY)
- 3D Printed Parts
- Right Angle Push Buttons
- Horizontal Push Buttons
- M3 bolts
- M3 Threaded Inserters
- Arduino Micro
Design
We began the project's design by drawing a basic concept that was based on the layout of a typical game controller, which has a PCB in the middle that houses all the components and two holding supports on the left and right sides.
Here, we created a PCB that is attached to the circuit is the left and right handles. The Arduino Micro is located on the back side of the board, while all of the buttons are positioned on the top side.
With a 0.4mm nozzle and a 0.2mm layer height, we used transparent PLA to 3D print the handle components.
Circuit
The Arduino Mini, which serves as the project's main microcontroller, is connected to 12 buttons in a particular sequential order.
Here, we constructed an arrangement resembling a voltage divider using twelve 1k ohm resistors connected in series with the button pins and VCC. The switch has resistors linked to one side and ground connected to the other.
An analog pin receives a value when a button is pressed; by reading this value, we can identify which button is being pressed. This makes it simple to integrate 10–20 buttons into a single I/O pin.
In the schematic, we have also included two thumb sticks that will be used in a future project.
Following the schematic's preparation, we made the board file and used the Cad file's layout to arrange every component correctly.
PCBWAY Service
Following the completion of the board design, we ordered a white solder mask with black silkscreen and submitted the PCB's Gerber data on the PCBWAY quote page.
PCBs were received within a week, and the PCB quality was outstanding. Here, we added a few design elements on the board's silkscreen layer to increase the aesthetic appeal of the project. PCBWAY made the custom layer properly, which shows their great PCB manufacturing capabilities.
Also, PCBWay is hosting its 7th Project Design Contest, a global competition that invites electronics enthusiasts, engineers, and makers to showcase their innovative projects. The contest provides a platform for participants to share their creativity and technical expertise with the broader community.
This year’s competition includes three major categories: electronic project, mechanical project and SMT 32 project
With prizes awarded for the most exceptional designs, the contest aims to inspire and support innovation, making it an exciting opportunity for both professionals and hobbyists to gain recognition and connect with like-minded creators.
You guys can check out PCBWAY if you want great PCB service at an affordable rate.
Circuit Assembly Process
- We start by adding the 1K 1206 resistor in its place by using a soldering iron. Here, we first add solder to one pad, then use a tweezer to pick up the resistor and melt the solder that was applied to the first pad. The resistor was then firmly fixed in place by applying solder to the other pad.
- By following this method, we added all 12 resistors in their place.
- Next, we placed all of the push buttons in their proper locations, including both horizontal and vertical buttons.
- We secured them in place by attaching solder wire to their pads, from the back of the board.
- Next, we attach two CON12 header pins from the back of the board to the Arduino Micro footprint.
- We solder the CON12 pads from the top side and fasten them firmly.
- Next, we use the previously inserted CON12 header pins to connect the Arduino Micro in its location.
- The circuit assembly is now finished.
Final Assembly Process
- We begin the final assembly step by inserting the threaded inserts into the 3D handle's mounting holes.
- Next, we use our soldering tip to heat the insert,, which forces it into place. For each of the four mounting holes, we followed this procedure.
- Next, we use four M3 bolts to attach the left and right 3D-printed handles to the circuit.
- Assembly is now completed.
CODE
We created a basic sketch for the project's code that is based on the Gamepad library, which you must install before using.
In this sketch, the single button, A0, is used to read the various values when any button is pressed. For instance, pressing the UP button yields a value of 0; pressing the Down button yields a value of 511.
Values for each button are different.
For each button, if the analog value from A0 falls within the specified range, the corresponding button is marked as pressed (true); otherwise, it's released (false).
In the below code sections, the microcontroller checks the value of A0 and sets the gamepad buttons accordingly.
if (value > -5 && value < 5) // UP gp.setButtonState(0, true); else gp.setButtonState(0, false);
The code reads an analog input from pin A0 and uses predefined ranges of values to simulate the press and release of gamepad buttons. Each range corresponds to a different button (UP, DOWN, LEFT, RIGHT, triggers, and face buttons like A, B, X, Y). The Gamepad object (gp) handles the state of these buttons by using the setButtonState() function.
To get values of each button, we used the Analog Serial Read Sketch from the example menu and used it to get values of each button.
Next, a table is prepared for recording all of the values, and tolerance values of +5 and -5 are added to the actual value. The tolerance value will be entered into the main code.
#include <Gamepad.h> Gamepad gp; void setup() { pinMode(A0, INPUT); } void loop() { int value = analogRead(A0); if (value > -5 && value < 5) //UP gp.setButtonState(0, true); else gp.setButtonState(0, false); if (value > 505 && value < 516) //DOWN gp.setButtonState(1, true); else gp.setButtonState(1, false); if (value > 762 && value < 772) //LEFT gp.setButtonState(2, true); else gp.setButtonState(2, false); if (value > 676 && value < 686) //RIGHT gp.setButtonState(3, true); else gp.setButtonState(3, false); if (value > 907 && value < 917) //LT gp.setButtonState(4, true); else gp.setButtonState(4, false); if (value > 930 && value < 980) //RT gp.setButtonState(5, true); else gp.setButtonState(5, false); if (value > 814 && value < 824) //Y gp.setButtonState(6, true); else gp.setButtonState(6, false); if (value > 872 && value < 882) //X gp.setButtonState(7, true); else gp.setButtonState(7, false); if (value > 847 && value < 857) //A gp.setButtonState(8, true); else gp.setButtonState(8, false); if (value > 890 && value < 900) //B gp.setButtonState(9, true); else gp.setButtonState(9, false); }
Result
The result of this little project is a functional game controller that can be used to play retro games that do not need analog thumbsticks.
Using a PC NDS emulator, we launched Pokémon Platinum, one of the best Pokémon games ever made, to test the power of this custom gaming controller.
Prior to anything else, the button layout needs to be configured. This was accomplished by choosing the emulator controller configuration and entering the button layout in the configuration.
The controller was extremely responsive and worked smoothly.
In addition, we appreciate PCBWAY's support of this project. Visit them for a variety of PCB-related services, such as stencil and PCB assembly services, as well as 3D printing services.
Thanks for reaching this far, and I will be back with a new project pretty soon.
Peace.
#include <Gamepad.h>
Gamepad gp;
void setup() {
pinMode(A0, INPUT);
}
void loop() {
int value = analogRead(A0);
if (value > -5 && value < 5) //UP
gp.setButtonState(0, true);
else
gp.setButtonState(0, false);
if (value > 505 && value < 516) //DOWN
gp.setButtonState(1, true);
else
gp.setButtonState(1, false);
if (value > 762 && value < 772) //LEFT
gp.setButtonState(2, true);
else
gp.setButtonState(2, false);
if (value > 676 && value < 686) //RIGHT
gp.setButtonState(3, true);
else
gp.setButtonState(3, false);
if (value > 907 && value < 917) //LT
gp.setButtonState(4, true);
else
gp.setButtonState(4, false);
if (value > 930 && value < 980) //RT
gp.setButtonState(5, true);
else
gp.setButtonState(5, false);
if (value > 814 && value < 824) //Y
gp.setButtonState(6, true);
else
gp.setButtonState(6, false);
if (value > 872 && value < 882) //X
gp.setButtonState(7, true);
else
gp.setButtonState(7, false);
if (value > 847 && value < 857) //A
gp.setButtonState(8, true);
else
gp.setButtonState(8, false);
if (value > 890 && value < 900) //B
gp.setButtonState(9, true);
else
gp.setButtonState(9, false);
}
Arduino Retro Game Controller
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(1)
- Likes(1)
- (DIY) C64iSTANBUL Oct 17,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Arnov Arnov sharma
- Delete Button XL Greetings everyone and welcome back, and here's something fun and useful.In essence, the Delete Butt...
- Arduino Retro Game Controller Greetings everyone and welcome back. Here's something fun.The Arduino Retro Game Controller was buil...
- Super Power Buck Converter Greetings everyone and welcome back!Here's something powerful, The SUPER POWER BUCK CONVERTER BOARD ...
- Pocket Temp Meter Greetings and welcome back.So here's something portable and useful: the Pocket TEMP Meter project.As...
- Pico Powered DC Fan Driver Hello everyone and welcome back.So here's something cool: a 5V to 12V DC motor driver based around a...
- Mini Solar Light Project with a Twist Greetings.This is the Cube Light, a Small and compact cube-shaped emergency solar light that boasts ...
- PALPi V5 Handheld Retro Game Console Hey, Guys what's up?So this is PALPi which is a Raspberry Pi Zero W Based Handheld Retro Game Consol...
- DIY Thermometer with TTGO T Display and DS18B20 Greetings.So this is the DIY Thermometer made entirely from scratch using a TTGO T display board and...
- Motion Trigger Circuit with and without Microcontroller GreetingsHere's a tutorial on how to use an HC-SR505 PIR Module with and without a microcontroller t...
- Motor Driver Board Atmega328PU and HC01 Hey, what's up folks here's something super cool and useful if you're making a basic Robot Setup, A ...
- Power Block Hey Everyone what's up!So this is Power block, a DIY UPS that can be used to power a bunch of 5V Ope...
- Goku PCB Badge V2 Hey everyone what's up!So here's something SUPER cool, A PCB Board themed after Goku from Dragon Bal...
- RGB Mixinator V2 Hey Everyone how you doin!So here's a fun little project that utilizes an Arduino Nano, THE MIXINATO...
- Gengar PCB Art Hey guys and how you doing!So this is the GENGAR PCB Badge or a Blinky Board which is based around 5...
- R2D2 Mini Edition So here's something special, A Mini R2D2 PCB that speaks ASTROMECH.Astromech is a fictional language...
- C-3PO Blinky Board Hey guys and how you doing!So this is the C3P0 PCB Badge or a Blinky Board which is based around 555...
- WALKPi Breadboard Version Greetings everyone and welcome back, Here's something loud and musical.Similar to a traditional walk...
- BOXcilloscope Greetings to everyone, and welcome back.This is BOXcilloscope, a homemade portable oscilloscope that...
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
95 1 1 -
-
-
-
Sega Master System RGB Encoder Switcher Z80 QSB v1.2
80 0 0 -
18650 2S2P Battery Charger, Protection and 5V Output Board
118 0 0 -
High Precision Thermal Imager + Infrared Thermometer | OpenTemp
556 0 7 -
Sony PlayStation Multi Output Frequency Oscillator (MOFO) v1
158 0 2 -