Introduction: Control Your 3D Printer With a Vintage Nintendo NES Controller and Octoprint
Ever since I built my 3D printer, I have really wanted a way to control it directly in addition to the Octoprint interface I have set up for it. While I could have added an LCD screen too, I stumbled across an original NES controller several years ago that I finally got around to hacking for use as an in situ controller for the printer. I grew up playing NES, so it's very satisfying to "play" my 3D printer when I'm getting ready for a print! It may seem daunting, but overall this took me less than a day to design, test and build and I hope with the details in this Instructable you can implement the same thing in way less time.
Supplies
To modify the controller:
- An original 7-pin Nintendo Entertainment System (NES) controller - NOT a modern USB controller.
- Look in thrift stores and yard sales to find them really cheap, they appear in spades on eBay as well!
- A soldering iron & solder
- A solder sucker or desoldering braid
- Wire strippers
- Flush cutters
- A Panavise or some way to securely hold the NES electronics board
- An old 10-wire ribbon cable or plenty of small gauge wire
- A Dupont-capable cable crimp or female prototyping jumpers
- Soap and water
- Rubbing alcohol
- A tiny Phillips head screwdriver
To control the 3D printer:
Step 1: Disassemble and Clean the Nes Controller
I managed to pick up the controller for this project from a home supply reuse store, similar to a thrift store. It was in good condition, but definitely needed to be cleaned up before use on this project! I remember getting lots of Dorito powder inside my NES controller as a kid, this one was no exception.
The controller comes apart very easily - there are six Phillips head screws on the back that come out with little effort, just be sure not to lose them. Once they are out, separate the back half from the front and pull the circuit board and cable straight up, being sure to detangle the cable from the labyrinth where it enters the controller. It is easiest to leave the front side of the controller on a work surface and lift the back off, rather than have all the buttons fall out on the floor.
The buttons and rubber pads all separate easily from the front of the controller. I took all of the non-electronics parts and soaked in warm soapy water, then brushed with an old tooth brush and rinsed everything off to dry for later. Inspect the rubber pieces and handle them gently - if the rubber is cracked you may need to touch it up with rubber cement.
I also took this opportunity to clean the contact pads on the board and the metal pads embedded in the rubber with isopropyl rubbing alcohol and a q-tip.
Step 2: Desolder the Chip and Cable
To get the controller to interface with a Raspberry Pi, it is necessary to remove the shift register chip and existing wires that connect the controller to the console. I found it easiest to hold the chip in my Panavise board holder, and use my soldering iron and solder sucker to desolder both of these. If you don't have a solder sucker, desoldering braid can be another option that is more readily available and less expensive, though investing in a solder sucker is not a bad idea if you're doing a lot of this type of work. Simply heat up the solder joint until the solder is soft, push the button for the sucker plunger, and voila!
Be sure not to damage any of the through-hole pads when desoldering - we'll need most of them to make this whole thing work again, so work slowly and gently remove the chip. You might need to go over the legs of the chip a couple of times to get all the old solder out for removal.
Step 3: How the Controller Chip Works and Testing
I did a bunch of work and testing to make it so that you don't have to, but wanted to share a bit about how this all works. You can skip over this step if you're just looking for instructions on how to recreate this for yourself. If you are looking for how to make an NES controller interface with a Raspberry Pi for other purposes, some of this might be useful.
What was very, very helpful was this video from Displaced Gamers about how the whole thing is wired up and uses the shift register chip to send signals to the console. I could not have done all of this without that video! I learned a lot, and after watching this came up with a good plan to make use of the board and switches to interface with the GPIO pins on a Raspberry Pi. In essence, we are going to use the existing contact pads and embedded pullup resistors by removing the chip, having each button interface with a separate GPIO pin, and reusing the 5V and ground connections to the board.
After watching the video, I desoldered everything and soldered on a header where the chip was and two prototyping jumpers for ground and 5V to power the board. This was only to allow me to test and experiment without making any permanent solder joints.
I then attached everything to an Arduino because I am more familiar with that platform than the GPIO pins on a Raspberry Pi, and ran a few tests on that to get a feel for what issues I might encounter. It was relatively straightforward - each switch pulls the pin it is attached to LOW, because it has an embedded pullup resistor in the board. This is a great feature for use for our purposes, as having an embedded pullup makes the switch more reliable and foregoes the necessity to somehow include one. The attached Arduino code is just a slightly modified version of the Button example, I used it to get a pinout for the board and label each wire for testing with the Raspberry Pi. I plugged in one at a time, pressed all the buttons to see which one made the integrated LED light up, labeled and moved on. The other sketch allows you to connect all 8 buttons at once, with each lighting up the LED when pressed.
Step 4: Add New Cable
Even if you don't go through the same process I did for testing with Arduino, I highly recommend getting everything set up on a breadboard and testing out the buttons before completing your new cable connector to the Raspberry Pi. I have a Raspberry Pi Cobbler from Adafruit that made this very, very easy for me. It allows you to attach the Raspi to a breadboard very quickly for testing!
See the attached pinout for the board - I took a screenshot of the video mentioned above, and added in labels for the 8 buttons. Besides the existing power and ground for the board, we'll need to solder in a wire for each of those to attach to a GPIO pin. There will be several unused pins leftover from the chip that you can ignore. Abbreviations are: SElect, STart, A and B buttons are labeled as such, and Up, Down, Left, Right.
I had an old computer ribbon cable with 10 wires kicking around - if you don't, you can use any regular wires from about 18-26 AWG. I'll note that hardware stores sometimes carry 18 AWG 10-connector cables for use in thermostats or for use in outdoor sprinklers if you are looking for a cleaner solution than 10 separate wires. See some of the next steps if you want to make a clean connector on the other end like I did, you'll need to solder things in the right order to allow for the connector to attach to the right pins on the Raspi.
I tinned the end of the wires going into the board and soldered them to each of the 8 switch connections, plus one for power and one for ground. I then finished the other end with my cable crimp to allow for the adding of female Dupont style headers. If you don't have a crimp like this, they are worth it! I've been doing electronics stuff for about 10 years and just bought it, don't know how I've lived without. You can always solder female jumper cables to the ends of your cable instead, it's just a bit more work.
Step 5: Install Octobuddy Plugin
This Instructable assumes at least a passing familiarity with Octoprint, the free and open source software to control a 3D printer. If you are new to Octoprint, get used to it first before tackling something like this! I have used Octoprint for a very long time and love it, I cannot recommend it enough for easily uploading prints to your 3D printer, especially if it is another room from your computer or you want fancy timelapses of all your prints. There is a lot of documentation for downloading and setting up for the Raspberry Pi elsewhere on the internet that I will not duplicate here.
We will be using the Octobuddy plugin to allow the NES controller to move the 3D printer axes, home the extruder and control the bed and/or nozzle temperature. Simply add the plugin by searching for it in the Plugin Manager. We will be selecting the pins for each of the buttons in the next step, but you can control each of the axes, heat the bed and nozzle, and home the printer. The NES controller only has 8 buttons, so you will want to decide which of these features you might be able to live without or add another separate button for them.
Step 6: Wire Up the Controller for Testing and Pin Assignment
I tested things extensively with Octobuddy to get the right pin assignments for each button before finalizing my cable - this helped a lot, as I made one soldering mistake and was able to very intentionally lay out the buttons so that my cable connector to the Raspberry Pi was pretty neat and tidy. NOTE: the Octobuddy GPIO board pin assignments are the number of the pin, not the GPIO designation. If you are confused by this, head over to Pinout.xyz. I pulled this up on my screen with the labeled diagram in step 4 to match my wires on the board with the best option for a GPIO pin on the Raspi for the connector so I could have the fewest number of plastic fittings for the ribbon cable.
I recommend powering the NES board with the 3.3V from the Raspberry Pi, not 5V (5V is what I started with, but my understanding is that the Pi prefers 3.3V for input signals instead of 5V). See the labeled images for how I configured my D-pad, Start, Select and A/B buttons. My printer is a Delta style so things are a little differently setup than you might see for a Cartesian printer, I recommend getting this all dialed in with prototyping before finishing up your connector - it is very easy to change the board pin in Octobuddy later to suit your needs.
The default 400ms debounce setting seems to work fine, but I did up my jog distance to 10mm instead of 5mm for quicker adjustments.
Step 7: Close Up Controller and Enjoy!
Once you are sure that all buttons are working and associated with the proper GPIO pin, simply close up the controller with the 6 screws. I added a small bit of tape but hot glue would work well too, there was plenty of room inside the controller to accommodate the new cable. This new feature for my printer will certainly accent my existing Teenage Mutant Ninja Turtle filament feed holders, and make it much easier to set up prints, change out filament, etc.
I'll note here that this Instructable really allows you to control anything on a Raspberry Pi through the GPIO pins, not just Octoprint and 3D printers! If you are looking for an inexpensive way to play NES emulated games, this might just be the Instructable for you to allow for a quick and easy way to convert an NES controller over for use by the Raspberry Pi more generally with just a bit of soldering and connector fabrication. While there exist other software solutions for getting an NES controller to interface with Arduino and the Raspberry Pi, it is very easy to simply solder in a cable as described to connect directly to the pins for each. Share your photos if you make this or something else using an NES controller modified in this fashion!