Arduino Game Controller for NES and GBA
by Arnov Sharma in Circuits > Remote Control
16256 Views, 32 Favorites, 0 Comments
Arduino Game Controller for NES and GBA
Greetings.
So here's a FUN little project that involves retro games:
To play classic games like Super Mario, Metroid, The Legend of Zelda, and many others, the Arduino Game Controller Project was constructed.
The internals of this NES-GBA Controller are buttons soldered on a perf board connected to an XIAO M0 Dev Board, which powers the entire controller. The controller's body is entirely 3D printed.
The XIAO M0 SAMD21 Dev Board from Seeed is compatible with the GamePad Library since it supports HID, which is crucial for this project.
This project cannot be built using well-known boards like the Arduino Uno or Nano, as they do not have HID support.
This Instructables is about how this game controller was built from scratch, so let's get started.
Supplies
The following are the materials used in this project-
- XIAO M0 Dev Board
- 12mm x 12mm Tactile Buttons
- Perf Board
- Wires
- Joystick Test Board
- Breadboard
- 3D Parts
Using XIAO M0 Over XIAO RP2040 or PICO
A DIY keyboard, mouse, or game controller could be made using RP2040-based boards like the Pico and XIAO RP2040, which support HID.
This project uses the Gamepad Library, which does not yet support RP2040 devices, although there may be another way to use the RP2040 as a gamepad.
Simply assigning all the buttons to the keyboard's up-down, left-right, A-B, etc. will allow us to create a straightforward keyboard that doubles as a game controller.
This will partially work, but the RP2040 will appear as a keyboard with buttons that resemble those on a game controller rather than as a gaming controller.
SEEED'S XIAO M0
Instead of the RP2040, Seeed's XIAO M0 was utilized in this case, a DEV Board powered by a SAMD21G18 chip that also supports HID and is the same chip used in the Arduino Tian.
The samd21 MCU, a 32-bit MCU with 256 KB of flash and 32 KB of SRAM, and an operating speed of 48 MHz make the XIAO MO the ideal board for this project.
It functions much like an Atemga32u on steroids.
This chip is a key component of Seeed's XIAO M0, a remarkably small breadboard-friendly development board that is a good alternative for standard Arduino boards.
The greatest thing about this board is that it only cost $5.
You can check out more details about the XIAO M0 below link-
https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html
Seeed Fusion Service
Do you know, Seeed Studio also offers PCB and PCBA services?
Seeed Fusion PCB Service offers one-stop prototyping for PCB manufacture and PCB assembly and as a result, they produce superior quality PCBs and Fast Turnkey PCBA within 7 working days.
Seeed Studio Fusion PCB Assembly Service takes care of the entire fabrication process, from PCB manufacturing and parts sourcing to assembly and testing services, so you can be sure they are getting a quality product.
After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.
Breadboard Version
We first attach the XIAO Board to a breadboard to start this project. The 10 IO Pins are connected to 10 tactile buttons from D0 to D9.
Each tactile button has a second pin that is connected to GND. Each I/O pin is pulled down when the button is pressed.
XIAO then reads the pin status and emits a signal through the USB port.
Only 10 of these buttons are utilized for the Left trigger, Right trigger, up, down, Left trigger, Start, Stop, and A and B, respectively, for the breadboard version. I'm using my previously made "Joystick Test Board," a Button Board built for quick prototyping of gamepad-related projects.
The code that is being used is a simple one. First, download and install the gamepad library from the URL provided below.
https://github.com/gamelaster/ArduinoGamepad/tree/master/examples
Then, use the attached sketch to turn any HID-enabled device—in this case, the XIAO SamD21—into a gamepad.
As of right now, there are only 10 buttons declared in this sketch, but more can be added by changing the code a little bit.
Downloads
Result
- We connect the XIAO Board to the PC and then open Devices and Printers to see if this configuration is functional or not.
- In devices and printers, you will see Seeed XIAO Board which has a gamepad logo, we right-click on it and see its properties.
- The Gamepad setup is confirmed to be functional by pressing the buttons sequentially from D0 to D9, which causes the button push to appear in the properties.
- It won't work right away because the gamepad keys aren't assigned, so we enter the emulator input settings and assign each key to a function. After that, we open the GBA emulator and load up a game.
- The game controller will function with this emulator after key mapping.
Custom Controller Design and 3D Parts
Three switch PCBs constructed of perf board or prototyping board are housed in the controller's rectangular housing, which was designed to resemble a NES or GBA gamepad.
In the following iteration of this project, the button boards will be built from proper PCBs; for the time being, we are using perf board. This model was created after the button boards were prepared.
The body was 3D printed with RED PLA with 20% infill, 0.2mm layer height, and 0.4mm nozzle.
Lid was produced using the same parameters from black PLA.
All of the board labels are optional, however, they require a finer setting, such as 0.16mm with a 0.2mm nozzle, to make them appear smooth.
Button Board Built
- We begin the process of building a button board by first gathering all the necessary parts, including a 12x12mm tactile switch and three perforated boards that will be used to create three distinct switch assembly parts, each of which will include a set of direction keys, A-B keys, and start-stop keys.
- To hold the Buttons in place, we first put them on the perforated board and solder their pads with a soldering iron.
- Next, using silver copper wires that can be recovered from THT components like LEDs or resistors, we link the GND pins of each button to one another.
Custom XIAO Breakout Board
- Following the preparation of the button boards, we prepare the XIAO Expansion breakout board using two female header pins and a perforated board piece.
- We solder the XIAO's pads and plug it into the perforated board, properly mounting it in its place.
The final product consists of three button boards with directional buttons, A-B keys, start-stop keys, and an XIAO extension board.
Controller Assembly - Adding Left Trigger and Right Trigger
After setting up the Button boards and XIAO Breakout board, we begin assembling the main controller by first using hot glue to secure the left and right trigger buttons in place.
Controller Assembly - Placing the Button Boards
- Then we use hotglue to secure the directional button board in its place.
- Next, we once more use hotglue to attach the A-B Button board inside the game controller Body.
- The start-stop button board is finally added in its place, and hotglue is used throughout.
XIAO Connection With Button Board- Ground Lines
Next, we set up a common ground for all boards by utilizing wires soldered to each button's pin to connect it to the GND pins on the XIAO board.
XIAO Connection With Button Board- Individual Button Pins
We next connect each I/O Pin to each button as specified in the code using the same wiring as for the breadboard edition, for instance, I/O D0 is connected to the left trigger, D1 is attached to the right trigger, D2 is attached to UP, D3 to down, D4 to left, D5 to right, D6 to A, D7 to B, D8 to start and D9 to stop.
To learn more, view the schematic that is included.
Result So Far...
As of this moment, each I/O pin from D0 to D9 is attached to a specific switch pin, and the other end of each button is connected to common ground.
When a button is pressed, the connected I/O pin is pulled down, and XIAO reads which pin is pulled down.
Testing the Controller
Using a multimeter set to continuity mode, we first examine this board's soldering by placing one end of the probe on an I/O pin and the other end on a switch pin.
After moving the probe to any I/O pin and ground, we press the button that is connected to the I/O pin, and continuity will beep, indicating that the I/O pin is being pulled down. We perform this test once more on each pin to confirm that everything is properly connected.
Next, we plug the controller into the computer and open devices and printers
We did this testing before, so we again checked the button press by checking the seeded XIAO properties, and yes, all switches are working properly.
XIAO Final Placement
We use hot glue to securely put the XIAO Breakout board in place after making sure that it is now operational and that all of the buttons are linked properly. I overused hot glue for this project, but there is no rule preventing its use.
Placing the Lid
Finally, we use four M2 screws to attach the cover to the controller's backside, putting the assembly process to an end.
Key Mapping
We reconnect the controller to the computer and start the emulator software; in my case, it is "Virtual Boy," a Game Boy emulator.
Since the controller won't function with any device directly, we must first map the keys in order to utilize it with any emulator.
We can use this device to play a variety of Game Boy or NES games after mapping the controls.
Game - Pokemon
I do recommend that you folks get all the ROMs legally.
the first game will be the Pokemon Gold Edition, a Game Boy Color game.
Pokémon Gold and Pokémon Silver, the second set of games in the Pokémon series, were published in Japan on November 21, 1999. Before gold and silver, there were the Pokemon RED and BLUE edition games for the original Game Boy, the first games in the Pokémon series to be created for the Game Boy Color.
The Pokémon Emerald, Ruby, and Platinum games came later, and they were all alright. Pokémon Lite Platinum was a remake of Gold, so it was good.
Personally, I like the gold edition because it is unquestionably the best Pokemon game in the series.
After beating each of the Johto and Kanto gym leaders in the game's finale, we also faced off against RED from the previous game at Mount Silver.
If you don't already know, RED was Ash Ketchum's counterpart in the previous Pokémon RED game for the GBC, but he wore red attire.
Game - Metroid
I then booted up the iconic Metroid game, which belongs to Nintendo's action-adventure game series. The player takes control of the bounty hunter Samus Aran, who defends the galaxy from Space Pirates and other evil entities who want to use the parasitic Metroid animals as a source of power.
The original Metroid game, which is being played here on a Gameboy emulator, was published in 1986 for the Nintendo entertainment system.
Because it uses the same keymap that was previously set up, the controls are the same as in the prior game.
Game - Ultimate Spiderman
Finally, we give Activision's Ultimate Spiderman—yes, the same firm that created COD—a go.
The action-adventure video game Ultimate Spider-Man, released in 2005, is based on the Spider-Man character from Marvel Comics and the comic book of the same name. For the PlayStation 2, Xbox, Microsoft Windows, Game Boy Advance, GameCube, and Nintendo DS, the game was released by Activision.
Here, the Game Boy Advance version is being played, and I must say, it's a good game.
CONCLUSION
This NES-GBA controller is functioning overall. Because of the pin function in the code, it should function as a direct controller if we plug it into any game station.
In the emulators, we must map the keys, but once we've saved the key function, everything seems to perform as intended.
Using a Pro Micro and Custom Board, I previously created an Xbox 360 controller that was used to play games like GTA 5. This NES-GBA controller is only for retro gaming, but it could be upgraded by adding joysticks to the board to become a proper analog controller.
That's all for today, folks. If you're interested in more projects of this sort, check out some of my previous work on gaming consoles and controllers.
Special thanks to Seeed Studio for providing XIAO for this project. Check them out if you need any electronic components at a lower cost.
That's it for now, and I'll be back soon with a brand-new project.
Peace out.