Introduction: Custom Game Controller

I have made my own game controller that I can connect to my PC and control a Unity game with. It's not a general-purpose controller. It's got very specific inputs and outputs that I have designed a game around and I imagine it would be pretty useless for any other purpose. Your needs might be different but perhaps some insight into my process will help you further along with creating your own controller. In this instructable I will summarize the steps I took making this controller, as well as share my code with you.

The controller consists of two turnable knobs that control a 2D object in Unity. The left knob moves it horizontally, the right knob vertically. The 4 LEDs on the top surface will have varying brightness based on the player's proximity to a wall in the game, with each LED corresponding to a direction. The goal of the game is to navigate from point A to B in maze-like levels, while being unable to see anything on the screen. The player must avoid the walls by looking at the LEDs to see where they are, kind of like feeling your way around a dark room except the walls are made of hot plates. If the player collides with a wall for too long, they die and must start over.

I'm going to assume you have some basic knowledge of electronics, Arduino and Unity, because the truth is I'm writing this for a school assignment due tonight, and I kept forgetting to take pictures because I'm not a dad on a family trip.

Supplies

PARTS

  • 1 Arduino Uno or similar model
  • 1 breadboard
  • 25x10 pin circuit board (smaller will probably do fine, I overcompensated a bit)
  • 250mm x 250mm x 4mm wood
  • 5 LEDs
  • 5 220Ω fixed value resistors
  • 2 10kΩ potentiometers
  • 2 knobs
  • A bunch of wires

TOOLS

  • Laser cutter
  • Soldering iron
  • Roll of tin wire
  • Hot glue gun

SOFTWARE

  • Unity
  • Adobe Illustrator
  • Arduino IDE

Step 1: Are We Making Bread? No.

The first thing to do is put the components together quick and dirty on a breadboard so that you can later write the code and easily test everything, and reassemble if needed. The schematic above shows you exactly how to do so. L1 through 4 are connected to variable output pins, as brightness levels will vary based on the output of the Unity game. L5 is connected to the 5V pin and just serves as an indicator that the device has power. The two potentiometers are connected by their middle pins to analog outputs.

Step 2: Staring at a Screen for a Few Hours

Once you have everything connected it's time to write the code that's going to run on your Arduino. Actually, you can just download the UnityPotControls.ino file below. Adjust the pin variables at the top if needed. You might need to change them again when you're done building your controller, because if you're like me, you will not have paid attention during final assembly and glued some LEDs in the wrong positions.

For setting up the game in Unity I refer you to my GitHub repository: https://github.com/narasu/arduino3/

Step 3: Do You Really Expect Just Anyone to Have Access to a Laser Cutter?

It's time to start cutting some wood! Put your sheet of wood into the laser cutter and feed it the box_v2.dxf file below. I generated a file using MakeABox.io and used Adobe Illustrator to draw the holes. The internal dimensions of the box are 100x100x50mm.

Alternatively, you could use a figure saw to cut out all the parts and a drill to make the holes. You can print the template by loading the file into Autodesk Viewer and spend the rest of your afternoon correcting your cuts because the pieces won't quite fit together. Unless you're more skilled in that sort of thing than I am.

Step 4: Burn Your Fingers a Few Times

At this stage, you're ready to start soldering. You can once again make use of my handy schematic if you forget what goes where. Make two lanes on the circuit board and connect one to the 5V pin, the other to the ground pin. I made these lanes by stripping and tinning two wires, then soldering the ends to the circuit board.

From there on, it's best to follow the schematic and see what works best for you, because my wiring is a mess and I do not recommend copying it.

Once you're done with that, glue all wooden parts except the lid together. Attach the potentiometers and the LEDs to the lid. Stick the Arduino and circuit board in with some double sided tape. Avoid getting glue on any exposed circuits. I learned that the hard way. You can now glue the lid on if you like to live dangerously. I didn't.

And that's it! Have fun with it!