Arduino Retro Game Controller
by Arnov Sharma in Circuits > Remote Control
530 Views, 8 Favorites, 0 Comments
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.
Supplies
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.
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.
Downloads
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.
Thanks for reaching this far, and I will be back with a new project pretty soon.
Peace.