Welcome back! If you’ve been following along then hopefully at this point you have a modified case with X/Y button holes ready to go, because we’ll be using those this week. For this part of the guide you’ll be cutting up and tapping into the original controller board from your (hopefully alread-broken) Game Boy, wiring it up to a Teensy LC board, and programming that to act as a keyboard.
A question about this project I get a lot is “Why did you use a Teensy in stead of just using the GPIO pins on the Pi?” It’s true, you can use the GPIO pins and a driver like mk_arcade_joystick and skip the Teensy. There are a few good reasons to do it the way I did, though:
- We’ll be using a couple of the GPIO pins that mk_arcade_joystick normally uses for PWM audio later on, and it’s kind of a pain to change the pins that mk_arcade_joystick uses (you have to compile it yourself if you do rather than using a pre-built one).
- The Teensy makes it much easier to change how your controller works. You can reprogram it to act like a joypad, keyboard, or even a mouse easily.
- If you ever need/want to reinstall a fresh copy of the latest RetroPie or try a different OS, there is no configuration you need to do to get the controller working; the OS just sees it as (in our case) a keyboard!
So, in my eyes, if you have room for it (which we do) then the Teensy is super handy.
Anyway, let’s get started. Here are the tools I used this week:
First we’ll need to remove some things from the board. All we really care about is tapping into some traces around the buttons, so you don’t need to be too terribly careful while removing stuff.
Remove the screen and the chip just below the screen from the front:
Removing chips like that can be kind of a pain. What I do is put a big glob of solder across all the pins on either side, which lets you heat up an entire side at one time and lift it up.
On the back, remove everything except for the staple-looking bits (they are bridging some traces on the other side that we’ll be using). Make it look about like this:
Now cut the board using a Dremel so it is right at 5.5cm tall (which should fall right at the top of the screen connector). It should go without saying, but the dust generated by cutting this is not something you want to be breathing in or getting into your eyes, so do it outside and use protection!
We need to remove the excess solder from the area where the X/Y buttons will go. The easiest way to do this is with a desoldering braid (you can get one for a couple bucks on amazon). Just rub it around on the parts with excess solder using the tip of your soldering iron and it will wick it away:
When you’re done that area where the X/Y buttons will go should be nice and flat:
Now we’re going to tap into the traces on the board so we can wire it up to our Teensy. Below is a high-res image of the board with the traces labeled (click to enlarge). There are also a few traces we need to bridge to create a shared ground (white with red circles around them below), which will make it easier to wire up to the Teensy.
Gently scratch off the top layer of small areas of each of the traces labeled above using something like a small flathead screwdriver, exposing the copper underneath. Don’t scrape too much or too hard, or you’ll wind up going right through the cooper part. It doesn’t matter too much where along those traces you scrape, just make sure you don’t do it in a spot that a rubber button base will be laying. Also try to space them out enough that you won’t accidentally bridge them when you go to solder it. Here’s how mine looked:
Fair warning: it can be a pain in the butt to solder onto these things. Applying a bit of soldering flux can help a little. For the bridged ground connections, you don’t necessarily need any wire, you can just put a big enough glob of solder on it to make the connection. It’s not pretty, but it works:
When you go to actually solder wires onto the board, it helps a lot if you get really thin and flexible wire. It’s also handy if you can get a different color wire for each button, so you can write down which one represents which button.
These connections are pretty delicate, so first check and make sure they are solid (you can use a multimeter to measure resistance across one end of each wire to the corresponding black button pad and make sure it’s a good clean connection). There is a great thread in the forums with links to guides/videos about using multimeters if you’ve never done that before. After you’ve checked that, apply some hot glue so you don’t accidentally break any of the connections.
Now we need to add contact points for our X/Y buttons (watching the accompanying video will really help with this part). First cover that area in electrical tape so none of the metal bits interfere with what we are about to add. Make it as flat as possible, and make it wrap over the top onto the other side. Then mark where your buttons are by putting your board in the front half of the case, and marking the board with a sharpie. This is what you should end up with:
Now we are going to apply 4 strips of copper tape. The inner two strips will overlap on the other side and will be a shared ground connection. The outer strips should run parallel to the inner two, close enough that when our buttons are pressed they will bridge the outer strip with the corresponding inner one (again, watch the video, it’s much easier to just see it done!):
At this point I put the board back in the front half of my case, along with the buttons, and tested with my multimeter to make sure the buttons actually bridged the connections.
Now on the back side, solder some more wires to the center, inner and outer copper tape strips. Also solder a small bit of wire from the middle strips to a nearby trace bridge (the staple looking bits). It should look something like this:
And a finished shot of the front (I actually forgot to do the Start/Select buttons until after I did all of the above, so that’s why this is the only shot that shows them finished. Oops!):
Alright, now it’s time to wire this thing up to your Teensy!
I’m using the ground pin, along with digital inputs 0-11. The order is Up, Down, Left, Right, A, B, X, Y, Start, Select, L, R (we’ll be wiring up L/R in another guide after we mount them in the case).
Once all the buttons are wired up, put the board into the case along with all the buttons and rubber bases — it’s time to program it and test it out!
First install the Arduino IDE, and then install the Teensy software. The latest version of the Teensy software (which is 1.28 at the time of writing) is not compatible with Arduino 1.6.9. You can either download Arduino 1.6.8 to use with it, or download the beta of version 1.29 of the Teensy software.
Make sure to run the Arduino IDE once and then exit it before installing the Teensy software. After that’s installed, download the Arduino project I wrote, which will turn the button presses into keyboard events.
Open up the .ino file. In the Tools menu in the Arduino IDE select Board, and select Teensy LC. In the Tools menu again, select USB type, and select “Keyboard + Mouse + Joystick”. Now click the checkmark in the top left to verify/compile the sketch. If it doesn’t complain about anything, hit the right-pointing arrow right next to it. This should open up the Teensy Loader app, and it might prompt you to click the tiny button on the Teensy itself. Do that if it prompts you, and it should upload the code, and you should be good to go!
Now you can plug it into any computer (or in my case a Game Boy Zero!) and try it out! It should be sending keypresses for w,s,a,d and a few other keys as you push buttons.
If you run into any problems or get stuck, jump in the forums and ask for help! Lots of nice people are already showing up there sharing advice, tips and tricks, etc.
Next time I’ll go over mounting the screen and the Pi Zero, as well as the bracket that we’ll make to reuse the original screw posts.
Don’t forget to register for the one I’m building in these guides!