Nano Game Controller
I’ve seen the Adafruit game controller tutorial, I mean it's good but with just 2 face buttons it is much below what you would want from such a device. So, I designed my own and I think it turned out pretty good. This article is written more like a tutorial so feel free to follow it if you want one as well. I used a Adafruit feather Bluetooth LE and a feather OLED attachment to get a visual output from the unit for debugging and to expand the capabilities of the device later down the line. But mostly because I think it looks really cool.
The first step was laying out the PCB, not wanting to require a custom PCB service I used thick perfboard and with the 50*70mm space I dint have much say in the matter as the microcontroller took up most of the space on the board, the angled switches need a bit of help going in but a bit of bending and you should get the same layout as me. I was going to use the built in pull-up resistors and Li-Po charger built into the feather so there really isn't that many things to connect. It really just is the buttons to the data pins and all the buttons to the Ground pin, and connecting the 720mah Li-Po to the feather, but with a in line switch so its not always on. This is a really good project if you just want to practice soldering as there is so much of it but not much to think about!
One leg of each of the buttons goes to Vout
The Li-Po battery to the Li-Po charger
← to pin 0
↑ to pin A0
→ to pin A1
↓ to pin A2
Left trigger to 13
Right trigger to 12
Left button to pin A4
Top button to pin 10
Right button to pin 1
Bottom button to pin 11
Use this image to layout the board, nice and big so you dont have to squint
I admit when it comes to assembly the design is pretty poor, I used adhesives instead of fasteners but hear me out plastic glue is much more common than self tapping m2 screws so unless you have those lying around this was for you mate ;). The assembly process is rather simple but follow these steps if you want a easier time.
First off the two pylons which come out of the faceplate are pretty thin so be cautious as they might snap during assembly.The thin spacer model is there if due to tolerance differences the original shell is too shallow in which case you have to make it deeper, I used one in my model to demonstrate that it can be used to give the design more visual flare.
The next step was designing the enclosure and I wanted it to tightly wrap around the board, I left standoffs in the corners so none of the pins stab the battery as that would be a disaster waiting to happen. You can get the STL files right here.
I made it as 3D printer friendly as possible and should print with out support unless your 3D printer is actually terrible.
Check you have about 40mm of wire for the battery and another 40 for the power switch so you can fit it in easely.
Put the battery in the device in the place where the pool of wires is the thinnest, if your feeling fancy use some double sided tape if the wires don’t keep it in.
Making sure there are no cables being crushed slide the perfbord into the case, the shoulder buttons should be at around this height and the USB port is easy to access as you will be needing it later.
Now on the Faceplate place in all the buttons ensuring they go in easily and can be moved with little to no resistance, now with the faceplate face down place the main body on it
then holding it together see whenever the D-pad is loose enough to operate and to hit all the diagonals, also check if all the buttons are high enough to not get triggered, if you find the faceplate pushes the buttons print out the spacers.
For final assembly do that all again with your adhesive of choice between the faceplate and the main element.
I spent much longer than I care to admit trying to get the gamepad API from here to work somewhat reasonably, windows machines ignore the D-pad inputs and android devices ignore the button inputs. This issue is because of API implementation being shoddy on both ends so I chose to use the good old fashion keyboard inputs. If you hold left on the D-pad when booting the device will use WASD as the D-pad output so use that for PCs and if it boots normally the D-pad will use the “direction hat” output for controlling android.
The screen is a basic debug output but I was really hoping to use this as a standalone machine and have things happen on screen, if you have any working code(I left the booting while right is held down for you to experiment) feel free to submit it. The code isn’t too well annotated as this is pretty old code and I doubt its a good place to learn.
Download the Arduino project here.