Close
0%
0%

Arduino Retro Game Controller

Made a Simple game Controller based around Arduino Micro

Similar projects worth following
0 followers
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 botto

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.

ps2Joystick v11.f3d

fusion - 2.23 MB - 10/16/2024 at 11:01

Download

handles.stl

Standard Tesselated Geometry - 806.14 kB - 10/16/2024 at 11:01

Download

Component22.stl

Standard Tesselated Geometry - 34.85 kB - 10/16/2024 at 11:01

Download

PROMICRO HOLDER.stl

Standard Tesselated Geometry - 34.07 kB - 10/16/2024 at 11:01

Download

  • 1
    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.
  • 2
    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.
  • 3
    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);
    }

View all 4 instructions

Enjoy this project?

Share

Discussions

Rich text editor

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates