Introduction: Raspberry Pi Powered SNES Controller
Do you like classic console and arcade games? Are you looking for a fun project with a steep learning curve and a great reward? If so, let's try to put a Pi Zero microcomputer into a SNES controller to emulate and play your favorite 80's and 90's games. We will also add some additional features to keep the fun high:
- Internal power supply
- Soft On/Off switch
- USB ports to charge and for external devices
- Keep controller functions
- Cut plastic
- Etch and populate circuit boards
- Solder wires
- Write some python code
What you will notice
- English is not my first language :-)
- I will use the metric system
- Links will refer to german providers
Step 1: Shopping List - Bill of Material
- Raspberry Pi Zero v1.3 - The heart of the build - Provider: PIMORONI, adafruit, PiHut (try to get a kit)
- Original SNES Controller - That is how we play - Best bet: Ebay (~15 € is a good deal, be aware of fakes)
- Micro SD Card (4GB+) - This is where our operating system will live - Amazon (check compatibility)
- 5V power supply with MicroUSB cable - To charge the battery - This or this will do it (~2A, 5V)
- USB Type A to miniUSB Type B adapter cable - Later we will charge from miniUSB- Amazon
- Blackberry LS1 battery - Our power supply - fits best - Ebay (the height is the critical parameter and should not exceed 5mm)
- Li-Ion charging board 1000mA - Charging board for our battery - Ebay
- Step up Converter - The battery will give ~3,7V but the Pi Zero needs ~5V - Amazon
- Slide switch - For a very basic on / off switch. This basic switch will just cut the power. This can cause SD card damages.- Amazon
- Mini HDMI to HDMI Adapter- To connect the Pi and the TV - Amazon (mini HDMI cable is also an option)
- Wires - To connect things.Try to get a small cross section (e.g. 0,08mm^2) - Amazon
- Solder - To connect electrical components and wires - Amazon
- Soldering flux - To create nice & strong solder connections - Amazon
- Double sided tape - This will keep the battery and the Pi Zero in place
- Screws and nuts M1,6- We need these to hold down the controller PCB - Ebay
Epoxy 2K adhesives (highly recommended) - To keep things in place - Amazon
[Optional] Advanced on / off switch
It's possible to use a simple switch to cut power. But I recommend using a soft On/Off circuit. This will shut down the Pi properly and avoid any SD card damages.
Since we will etch the conductor board ourselves we need few more things.
- Momentary switch - To turn the system on and off - Ebay, Amazon (fancy with LED)
- Conductor board without photoresist coating - This will hold our electrical components - Conrad
- Dual Diode BAT54C - Makes sure that the current runs in the right direction - Conrad
- Dual Mosfet IRF7319 - Heart of the circuit to switch between on and offstate - Conrad
- 2x 300k SMD 0805 Resistor - Yes SMD we don't have much room - Conrad
- Iron(III) chloride - To etch the PCB - !ACID! - Amazon
- Glossy paper or photo paper - To transfer the circuit layout to the conductor board (any magazine paper will work)
- Laser printer - We need a laser printer (ink won't work) to print the circuit on our glossy paper
- Flat Iron - To transfer the circuit layout from our glossy paper onto the PCB
- Protection gloves and glasses - THIS IS NOT OPTIONAL
[Optional] USB connection
You can cut big holes in your SNES controller in order to have access to the USB capabilities.
Since I do not want to have big holes in my case I will extend the USB connectors from the Raspberry Pi and the power supply.
- MiniUSB Female SMD Connector - Our final power supply connector - Ebay
- USB Type A Female SMD Connector (ideal length ~10mm) - Our final USB connector - Ebay
- Micro USB 5 Pin connector - We need this to extend the micro USB connector comming from the Pi to the USB Type A connector - Ebay
- Personal computer with SD card reader
- Micro SD card reader adapter
- USB Stick
- Solder iron
- Multifunction rotary tool like a Dremel | Tools: drills, engraving cutters , abrasive belt
- Sanding paper
- Hobby knife - This is pretty good
- Tweezers - This type
- Side cutter - Amazon
- Small set of rasps - Amazon
- Third hand - This or your partner will hold the wires - Amazon
- WLAN stick - Makes installation so much easier - Amazon
- Micro USB Hub - To attach temporary periphery like keyboard, WiFi etc. The final build will use USB Type A- Amazon
- Desoldering braid - Good to have if you mess things up - Amazon
- Multimeter - Conrad
Step 2: Setting Up the SD Card
[Required] Installing Raspbian Linux and Retropie under Windows
In this section, I will describe how to install the required software components. We will use Raspbian Linux as operating system and Retropie as emulation software.
Installing Raspbian Linux & Retropie (also see Github)
- Download and install Win32Diskimager - Sourceforge
- Download the Retropie Image - Use the "Raspberry Pi 0/1" - Link
- Unzip the archive using 7-Zip
- Put your micro SD card into the card reader and start the Win32Diskimager
- Select the image and output devive and press start
If you have any trouble try this page for further reading.
[Required] Basic configuration
- Take your Pi and put in the micro SD card
- Connect the HDMI adapter and the micro USB hub with Wifi stick and a keyboard
- Connect the microUSB charger to start the Pi
- Wait until you see the Retropie main menu
- Hold the "Enter" key on your keyboard to configure basic navigation with your keyboard. I used the following mapping:
Left: left arrow key
Right: right arrow key
Up: up arrow key
Down: down arrow key
Skip the rest holding an arbitrary key. Be patient, the system will need some time to save the changes.
- Now we want to make some basic configurations
- Press the "A" key to enter the Retropie menu
- From here select "Raspi-Config" and hit the "A"-key. This will bring you to the setup section.
- Select Option 1 "Expand File System" and confirm your changes. This will increase the partition size on our SD card.
- Select Option 4 to setup your time zone and keyboard layout
- Select "Finish" in the root menu once you are done and confirm to reboot
- To enable Wifi go to the Retropie main menu and select "Retropie Setup"
- Select "Configuration / tools" scroll down and select "Wifi - configure Wifi"
- Select "Connect to Wifi network"
- Select your Network and confirm
- Enter your WLAN key and confirm
- You should now see your IP address
- Exit to the setup main menu
[Required] Installing "gamecondriver"
We need to install the "gamecondriver" in order to connect our SNES controller directly to the Pi Zero GPIO's. The GPIO's (General Purpose Input Output) are the pins on your Pi.
- Start the "Retropie Setup" (when you are not already in)
- Select "Manage package" in the setup main menu
- Select "Manage driver package" and "gamecondriver"
- Select "Install from binary" (Wifi required)
- Wait until the installation process is finished
- Back in the menu exit to the setup main menu and reboot
- Back in the Retropie application just hit F4 to exit to the console
- Type "cd /etc/modprobe.d" (without exclamation mark) this will change the directory
- Type "sudo nano gamecon.conf" - "nano" is a text editor and "gamecon.conf" is the configuration file we need to change. To access the file with administration rights we need additionally the "sudo" command.
- Change the string to "options gamecon_gpio_rpi map=0,0,0,0,0,1" - This is because of the wiring we will use.
- Press "Ctrl+X" to exit and "Y" to save.
- Press Enter to confirm the file name.
[Optional] Shutdown script for the soft On/Off switch
If you want to add the soft On/Off switch, you need to add something to tell the operating system to shutdown when you press the momentary switch. This 'Something' is a short python program. The program will listen to any changes on GPIO 23 and trigger the shutdown command.
- Start the Pi and press F4 to exit to the console (if you are not already there)
- Type "cd /home/pi" to change directory
- Type "mkdir GPIO" to create a new directory for our code
- Type "cd GPIO" to change to that directory
- Type "sudo nano pishutdown.py" to create a new file for our code called "pishutdown.py".
- Add the below-mentioned python code and save the file
- You can test the code using "sudo python pishutdown.py"
- Since we added an infinite loop, we have to terminate the program using "Ctrl+C"
import RPi.GPIO as gpio<br>import time import os gpio.setmode(gpio.BCM) gpio.setup(23, gpio.IN, pull_up_down = gpio.PUD_UP) def Int_shutdown(channel): os.system("sudo shutdown -h now") gpio.add_event_detect(23, gpio.FALLING, callback = Int_shutdown, bouncetime = 2000) while 1: time.sleep(1)
- We will use "crontab" to start the program every time the system starts or reboots - Crontab is a control file to schedule certain tasks
- Type "sudo nano /etc/crontab -e"
- Add as last line the code below
- Save and Exit
@reboot root /usr/bin/python /home/pi/GPIO/pishutdown.py<br>
[Recommended] Backup your SD Card using Win32Diskimager
Step 3: SNES Controller Preperation
- Open the controller using a small screwdriver (make sure you keep the screws)
- Detach the cable from the controller board by pulling it out
- Remove all other loose parts like buttons and rubbers (yes... keep them)
- Use a side cutter to remove the connector and desolder the remaining pins from the other side using your desoldering braid (video tutorial 4:30min). We will later connect some wires from here to the Pi Zero.
- Solder new nice contact points for the 5 pads
- Use a side cutter and/or a rotary tool to remove the plastic parts shown in the first picture. Please wear some EYE PROTECTION when using a rotary tool.
- Flatten things with sandpaper.
Step 4: Power Supply
[Optional] Controller Board Fixation
Before we start wiring the power supply, we need to make sure that the controller board will sit tight next to the controller buttons. Since we removed the mount for the left screw we will simply add a new one:
- Drill a small 1,6mm hole at the position shown in the second picture
- Plug the screw in the controller board
- Put the controller board in the case and measure the required screw length
- Cut the screw with a rotary tool if necessary
- Take the controller board out and mix some Epoxy 2K adhesives and put some on the bottom of the case (where the screw will touch the case)
- Put the controller board with screw back in the case and align the screw
- Wait until the adhesive is hard enough to remove the board without the screw
- Add additional epoxy to fix the screw
- Remove the top of the small plastic pillar in the middle of controller board
Wiring The Power Supply
- Place the battery on the left side (see picture) and make sure that the battery is not covering the screw holes.
- Mark the position of the battery with a pencil
- Place the charger and the step-up converter to the right.
- [OPTIONAL] If you want to charge with the micro USB coming with the charger, place the charger right next to case wall.
- Solder some wires from the positive and negative battery pad to the corresponding pads on the charger board (How to solder wires). Don't change polarity!
- The charging board delivers only 3,7V. To boost the voltage to 5V (required for the PI) we need to connect the charger output to the step-up converter. We will later add the soft On/Off circuit between the charging board and the step up converter.
- Make a short test charging the battery. If you have a voltmeter, measure the voltage output coming from your converter. It should be around 5V+
- Use double sided tape to fix the battery, the charger, and the step up module
Basic Power Switch
I do not recommend a basic on / off switch because of possible SD card damages. But it's much easier to build.
- You need some sort of switch (e.g. a slide switch)
- Find a good place for your switch (see the last picture)
- Solder the switch between the positive output of the charger output and the boost converter (see scheme picture)
- Test it
Step 5: Optional - Advanced on / Off Switch
The soft On/Off switch will shut down the system and turn it on. Therefore we need a small circuit with two transistors. Here you can find a detailed explanation how the circuit works (credits to Othermod!).
I used eagle to design the PCB layout. There is a basic 'free to use' version.
Etching the PCB
There are a lot of Instructables out there with a detailed explanation (e.g. this one). Here is my own short version.
- Print out the PCB circuit template (see SoftOnOffSwitch.pdf) on glossy paper (e.g. magazine paper) with a laser printer (ink will not work)
- Measure and draw the PCB dimension on the conductor board (approx. 1,1cm x 1,8cm)
- Use your Dremel or a metal saw to cut the conductor board
- Get your flat iron and ironing board and put the template onto the PCB (printed side onto the copper side)
- Iron the PCB with the template (take your time)
- Peel off the paper with some water (slowly)
- NOTE: If it is not perfect use a water resist marker (like a black Edding) to fill gaps
- Get a plastic container, safety gloves and the etching solution (ferric chloride)
- Pour the etching solution in the container and leave the board for approx 45mins
- Take out the board with a tweezer and rinse with clear water
- Take some sanding paper and remove the ink
Soldering the components
- Look at the PCB layout and solder each of the components (BAT54C, 2 x 300k resistor, IRF7319)
- Attention: the dot on the housing indicates the correct orientation of the IRF7319.
- I used this technique to solder the SMD components. I can't explain it any better.
- Add wires to the pads like shown in the picture
Step 6: USB Connectors
In this section, we will add two USB ports. One for charging the battery (mini USB) and one for the USB OTG port.
MiniUSB Charging Port
- Mark the outlines of the mini USB connector on your controller case. I used an ink pad with the USB connector as a stamp in order to get exact outlines.
- Use your rotary tool and cut along the outlines. I used an engraving tool.
- Use a rasp to get a good finish (this set is pretty good)
- Solder a wire for ground and VCC at the USB connector (see picture)
- Mix some 2K adhesive and glue on top of the wired pins in order to get a strong connection.
- Put the USB connector in the case
- Use the 2K adhesive on all sides of the connector. Don't glue the bottom side directly on the controller. Otherwise, it's pretty hard to plug in the cable later on.
- Wait until the adhesive is hard enough
- Solder the ground and VCC wires to the corresponding pad on the charging board.
USB Type A Connector
- Solder the wires for ground, VCC, data- and data+ to connect the micro USB male connector to your USB Type A connector (see picture). The micro USB from the Pi Zero will sit later above the USB Type A connector. So keep the wires short.
- I highly recommend putting some 2K adhesive on top of the soldered connection.
- Mark the outlines of the USB connector on your controller case. Again, use an ink pad if possible.
- Cut the case along the outlines
- There are two small pressure pads on the top side of the USB connector. Since we will assemble the USB connector upside down we need to bend and cut the pads, so that ~1mm of pads will remain. If we don't cut the pads, it will be very hard to plug in the USB cable later on. If you use a longer USB connector (>10mm) you don't necessarily have to do this.
- Cut some small slots in the controller case. These slots will borrow the remaining 1mm pads.
- Cut and rasp until everything fits. Also, double check if the SNES controller board still fits.
- Glue the USB connector in place using the 2K adhesive.
Step 7: Wiring and Assembling
Wiring Everything Together
- Solder five wires on the bottom side of the controller board
- Glue the soft On/Off circuit board in the middle of the controller case
- Place all the buttons and rubbers
- Mount the controller board
- Plug in the miniUSB male adapter into the Raspberry Pi
- Attach the Raspberry Pi with double sided tape on top of the battery
- Start soldering the miniUSB power supply wires to the charger board (see schematic)
- Next solder all the wires for the on / off switch (see schematic)
- Finally, solder all the wires coming from the SNES controller board (see schematic)
- Cut the mantle of the HDMI adapter in order to pass the battery
- Cut a hole, corresponding to the size of your HDMI adapter, in the SNES cass
- First, we need to fix the trigger buttons. There is not enough room for the bearings. Use sanding paper to flatten the bearings until they fit.
- Assemble the trigger buttons
- [Optional] Drill a hole in the middle of the case to reduce the heat coming from the Pi
- Close the case and turn in the screws
Step 8: First Start & Adding ROMs
- Plug in an HDMI cable and connect a keyboard
- Hold down the momentary switch for 2s. The Pi Zero should boot
- Once the menu is displayed press select on your keyboard and select "Configure input"
- Configure your SNES controller
Adding Game ROMs
You have to own the original game in order to use a game ROM on your Pi.
There are several ways to add game ROMs to your Pi. I will describe a simple method using a USB drive.
- Plug in a USB stick in your PC and create a folder called "retropie" in the root folder
- Plug in the USB stick in your Pi and wait until it boots up - This will automatically create a folder structure on your stick with all supported consoles
- Take out the stick and copy your gaming ROM's from PC in the corresponding folder
- Plug the stick back in the Pi and boot. The games should show up.