Wireless NES Controller

NES1

This project is a modified wireless NES controller which is USB compatible with windows. It has the modern functionality of today’s controllers but the look and feel of the original classic.

Note: Even though this project has long been officially retired, I am still actively working to update this page and it’s documentation.  Please pardon the mess.

Acknowledgements
This project features work or was inspired by work from the following individuals:
Dean Cameron | LUFA USB Stack
Darran Hunt | Arduino Hacking Blog
Mark Feldman | ppl-pilot.com
Ryan97128 | Nintendo Controller MP3, Version 2.0
Mike McCauley | Virtual Wire Library

Project Source Code
Link | (Github)

WIRELESS NES Controller Schematic

Problem Space
Nowadays, anyone can buy  a wireless or Bluetooth video game controller for their computer and play old school video games using an emulator. But I prefer the feel of the original NES controller when playing all those classic games because it helps bring back a sense of nostalgia each time I play. At the same time, I have grown accustomed to the wireless features of today’s controllers and find going back to having a ridiculous controller cable draped across the living room a hassle. From a historical perspective, there actually were a few wireless NES controllers that were mass produced during Nintendo’s heyday, but many if not all of those solutions were based on infrared transmission technology, and likewise suffered from the same line of sight and interference issues your television remote does. This issue made games nearly unplayable, and is the reason those controllers were never a big hit. This project is my attempt at to fix that problem from years ago by giving the original NES controller a modern wireless upgrade. Additionally, this project would become an important step in my journey toward understanding electricity and what programming was all about. Roughly a year later, I had a modified classic NES controller in my hands which is wireless, rechargeable and USB compatible. Completing this project is part of what inspired me to go back to school and become an engineer.

Basic Features:

  • The NES controller transmitter contains an atmel328p IC running the Arduino bootloader.
  • Light up “Nintendo” logo w/ custom wakeup, sleep, low battery, shutdown, and startup LED effects.
  • Internal 3.7V IPod Nano Lipo battery (boosted to 5V).
  • Sleep mode after inactivity (with LED warning pulse).
  • Wake from sleep on button press.
  • Transmitter can be easily modified to work with other controller protocols  (SNES, ATARI, etc.)
  • Physical On/Off switch
  • 2.5mm barrel jack for insertion of a polarized charging cable.
  • 4-wire JST connector for quick controller firmware updates.
  • Uses an RF Link 315Mhz receiver and transmitter pair running at 4800 baud.
  • The Base-Receiver is an Arduino Uno with the Atmel 8U2 flashed with custom firmware to appear as an HID joystick in windows.

Development Cycle

Background information
I was nearly an absolute beginner in both in electricity and in programming at the start of this project. Additionally, I had just finished building my first HTPC, which I put a bunch of old school emulators and games on that i wanted to play. At around this same time, I also become very curious about electricity. I saw a special on TV hosted by a yet-to-be-famous Bre Pettis (future co-founder of the popular 3-D printer company Makerbot). In that special, I saw Bre charge and power an odometer on his bike using magnets attached to his bike wheels. After seeing that, I walked into the local radio shack and bought a battery, wire, a switch and a light bulb and started doing my own experiments. I also heard about something called an Arduino, and took the “Intro to Arduino” workshop at NYCResistor, a makerspace close to my apartment. That 3-hour class taught me how to solder and put together a Freeduino (Arduino-clone) and program it. Up till this point, that was my only soldering experience. I also wrote my first piece of C code while I was there, blinking S.O.S. in a loop. I got a thrill from these experiences, and I saw this project as the perfect opportunity to continue having that thrill. I started discussing this wireless controller idea with friends and they were all very supportive, but I’m also sure they secretly thought I was over reaching. I can’t say I blame them. How many non-engineers do you know who just suddenly “want to make a wireless video game controller” out of the blue, and go off doing it? I didn’t know anyone either, quite frankly. Which also meant I’d have to figure much of it out on my own. I wouldn’t have someone I knew who I could go to when I had questions. But by the end of this project, I learned how to go out and get many of these answers for myself.

I started on this project by narrowing down the scope of the project to a few main goals and wrote down any questions I’d need to answer.

Major Design Goals
1) Read the buttons of an NES controller and store which are currently pressed and not pressed
2) Modify that controller to be battery powered and rechargeable
3) Make the controller transmit it’s current button states across a living room (in a reliable way)
4) Make the receiver unit pass these received button presses off to a windows PC
5) Make the computer read the received button presses as a USB joystick (preferable) or as USB keyboard presses.

Questions I had at the start of this project which needed to be answered to complete it:
Is the Arduino the right microcontroller for this project?
How do I read a button with an Arduino?
How does a video game controller work?
How do you read/make an electrical schematic?
How do I measure and test my circuit before I implement it?
How does a multi-meter work?
What are the different hardware and software methods used by video game consoles for reading and sending button presses?
What wireless communication technology should I use?
How does wireless communication usually work?
What commercial wireless transmitter units will work best with Arduino?
Will there be any noticeable “button press” latency in this system?
How should I best measure the latency in my system?
Will any component necessary for completion of this project be really expensive?
How do I safely use, monitor, and recharge a LiPo battery in a project?
How big of a battery do I need?
How is battery capacity measured? units?
Can I fit an Arduino, LiPo battery, wire and everything else inside the existing cramped space of a video game controller?
How can I make an Arduino send custom messages to my computer?
How can I make the computer think I have a USB joystick?
How can I update that “USB Joystick” with my button press data?
How does USB protocol work and how do USB joysticks typically collect and send data?
Is there anyone else out there who has done something like this before?
Where are some good places to find answers to some of these questions?

After compiling questions, I methodically pieced together a high-level development plan based on all of the above, in an order I thought made the most sense to me, and began to research, implement, and test each item as it was completed. The nice thing about my chosen development plan was that it was high level and flexible enough that I was free to modify and adjust to any new unknowns as they presented themselves in the development cycle. It also allowed me to fill-in any low-level objectives as development progressed.

Development Roadmap
1) Use an Arduino to read a single button on a breadboard. Test by printing the output to the screen.
2) Figure out how the Atari, NES, and Sega Master system controllers are electrically wired.
2) Start with the simplest controller (Atari), and read all of it’s buttons using an Arduino. Test by printing the output.
3) Find/connect a cheap wireless solution for the Arduino. Send a simple message wirelessly across the living room. Test by printing output on the receiver.
4) Combine the code from the Atari and the wireless solution. Test by making the atari light up LED’s from across the living room.
5) Replace the Atari controller in the system with an NES controller. Change the arduino code to read NES button presses instead.
6) Research LiPo battery characteristics. Find a small enough battery. Design/pick a LiPo recharge circuit. Test by charging a battery.
7) Create a “bare-bones” minimal Arduino circuit on a breadboard. Estimate if it’s small enough to fit inside a controller.
8) Figure out how to program a bare bones Arduino in on a breadboard without using a USB cable. Test it by uploading a blinky sketch.
9) Create a working electrical schematic of all of the pieces put together. Solve the circuit using ohms law. Check and re-check calculations.
10) Solder and connect the electrical modules together. Test continuity using a multi-meter.
11) Fit everything inside the NES controller. Test by making the NES controller wirelessly light LED’s across the living room on the receiver.
12) Figure out how to implement a USB joystick solution which can be recognized by my PC and how to best interface with it.
13) Connect the receiver Arduino to the USB solution, and tell the USB solution what buttons are being pressed to update the PC. Test by playing a game.

This is a video I made while testing the wireless transmitter/receiver using an Atari controller. You can see that it blinks LED’s controlled by a receiver Arduino set up across the living room.

Hardware Breakdown and Modifications
The controller’s main IC is a bare-bones Atmel 328p running the Arduino bootloader, which reads and controls the NES pad’s shift-register in order to read all of the button states. The transmitter code was written in Arduino’s variant of C. The receiver unit is an Arduino UNO, which has it’s internal 8U2 IC’s firmware flashed to present itself as a video game controller to the host PC. The Arduino UNO base unit, plugged into my HTPC, receives button state messages from a 315MHz RF Link transmitter over the air and then passes along that information via standard UART to the 8U2 chip. The 8U2 chip organizes the button presses into a special USB HID report packet and sends that message off to the host PC continuously.

Controller Case Modifications
I cut out a lot of unnecessary plastic support pieces inside the controller with my Dremel, in which I followed pretty closely to Mark Feldman’s modifications. (see: Front Plate Preperation section of his site). This allowed me to fit all of the extra electronic componants, including the battery, inside the cramped space of the controller. Additionally, small square incisions were cut into the the top of the controller to fit the programmer connector and a small on/off switch. Lastly, the entire label on the front of the controller was carefully peeled off/removed and a long trench of rectangular plastic was cut out from just underneath where the Nintendo logo is placed. I glued a diffused piece of clear plastic (for the LED’s to shine through) in that channel. Details on how to do that can be found in steps 6 and 7 of Ryan97128’s Instructables tutorial.

Controller Power and Battery
Power was supplied by a thin 400mah 3.7V Ipod mini battery I bought off EBay, inspired by it’s selection in Mark’s project. At the time, (2009-ish) small thin lipo batteries were not as plentiful, nor as cheap as they are now. I believe in todays market you should be able to find an even thinner/smaller lipo battery for about the same mah rating for much cheaper. Voltage from the battery was then boosted to 5V using a pololu boost regulator which went on to power both the 328p and the HopeRF transmitter. A 2.5mm barrel jack socket sits in the original opening for the controller cable and acts as a proprietary power plug connector for an external charger. A tiny on/off switch sits near the right index finger to shut off all power from the battery to the controller. When i wasn’t using the controller, I plugged in a 2.5mm male audio jack at the end of a wire connected to a sparkfun lipo charger (based on the max1555) to recharge the controller. Because LiPo’s are sensitive to over-voltage and under-voltage charging and usage conditions, the atmega328p actively monitors the battery voltage and powers down the controller when the battery level dips below ~3.3V. To conserve battery life, the controller puts itself into a low power sleep state when inactive for 7 minutes (ie. no buttons pressed). The controller can be woken up by holding down the select button (or another button if wired appropriately). The LEDs within the Nintendo logo flash to indicate the transition between different powered states. (startup, sleep, low battery, shutdown etc.)

LED logo FX


The logo is lit by 2 (red) LED’s from inside the controller through a diffused piece of clear plastic placed directly underneath the logo.

Behind the LEDs, I put black electrical tape to help keep the light from escaping and shining out of other areas of the controller. The original black lettering on the Nintendo Logo painted on the front sticker itself was actually carefully and painstakingly chipped away by hand with a toothpick and nail polish remover in order to allow the diffused LED light to shine through the lettering. The necessary details for this portion of the project can be seen in Instructable’s user Ryan97128’s Nintendo Controller MP3, Version 2.0  project blog (specifically steps 5 through 8).  Once the modification was done, the sticker was put back on the front of the controller. PWM is used in software to create the custom logo effects for wakeup, sleep, low battery, shutdown, and startup events.

Wiring
There is actually a lot of wire routed in this project, because it is not implemented with a custom PCB. To help fit all of the wires inside the actual controller, I used really thin wire wrap wire (24 AWG or more), which was the thinnest kind of wire I could find. It is very brittle however, and it can potentially break very easily by tugging on it too hard when opening up the case so I had to always be very careful when taking the controller apart to test it. 

RF Communication
I used a cheap 434Mhz RF Link pair ( transmitter | receiver )  that I bought from Sparkfun to send payloads one way from the controller to the base unit at 4800bps. I cut ~6 inches of wire for the antennas, and wrapped the transmitter antenna around the perimeter inside the NES controller. This transmission pair is nice in that it forwards standard UART serial data at 4800 baud over the air without much modification, but I found that data reception success rate was very sporadic with attached antennas. But when researching the issue I stumbled across the VirtualWire library by Mike McCauley, and once I integrated that library I had no more communication issues at all and everything transmitted perfectly.

Software
For this project I used a Arduino Uno rev2 which includes a removable atmega 328p IC. I programmed the onboard 328p chip with the transmitter code first, then physically removed the IC from the UNO and replaced it with a brand new 328p chip that included the arduino bootloader. I then I uploaded the reciever code onto the new 328p chip using the Arduino IDE.  Next I installed Atmel Flip to burn firmware to the 8U2. Note that once you burn the custom hex file to the 8U2, the UNO’s neighboring 328p IC can no longer be programmed using a USB cable. Note: In order to reprogram the UNO’s main IC after this point, you must re-burn the ORIGINAL 8U2 arduino firmware back onto the chip to restore its USB serial functionality.  You may wish to try using the 6-pin ICSP header for programming the UNO’s main chip, since I believe that method should still work even with a reprogrammed 8U2.

Once the base unit code was uploaded, I put the arduino’s onboard 8U2 IC into DFU mode using these instructions for the UNO rev2, and uploaded the new hex file via Atmel’s FLIP software. Atmel Flip can be downloaded here and Instructions on how to change to 8U2 firmware on the arduino using Atmel flip are listed here. The hex file is a compiled binary of the Lufa Library (ver. 100807) with a custom USB HID descriptor which describes a large single player joystick with 32 buttons. Much of the code compiled into that hex file was adapted from code written by Darren Hunt And Dean Camera, so please visit their sites and support all of their projects. Darran’s original 8U2 source files can be found here and the Lufa Library (Version 100807) can be found here.

Updates that are coming soon: 8U2 Hex File, BOM, Base Station Schematic

 

 

Bookmark the permalink.

Leave a Reply