Introduction: Control Your NES by Motion!

In this instructable I will explain you how to control your NES by motion. This may seem difficult but it's actually pretty simple.

The Nintendo Entertainment System from 1985 had many different controllers, for example the power glove, the u-force and the roll & rocker.
We'll add another controller to that list today by building a motion powered controller.
The way this works is that an android device is connected via a bluetooth connection to an Arduino. The android device is running a special app that will send it's rotation and whether it's shaken. The Arduino receives this information and simulates the correct button press on the NES controller via a shift register. The NES will think a button has been pressed on the controller and returns the feedback in the game.

By tilting the phone to the left or right the d-pad will be pressed to the left/right and by shaking the phone the A button is pressed.

BTW this kind of control would be great for disabled retro gamers because you only need one hand to use the android device.

Let's build it!

Step 1: Parts Needed

Things you will need:
• Arduino
• 4021 shift register IC (these were used in NES controllers as well)
• NES controller cable (you can cut these from your old NES controller)
• 2x 3.6kΩ resistor (for PAL NES only, if you live in Europe your NES is PAL)
• HC-05 or HC-06 Bluetooth module (you can get one on Ebay for about $5)
• Breadboard
• An Android phone or Tablet
• Jumper wires
• An NES of course!

Step 2: Build the Hardware

Just follow the schematic I made and build everything on a breadboard. It might turn into a wire mess but if you keep following the schematic I guarentee it will work.
If your NES is not European then don't place the two resistors. Connect the colored wires from the NES controller wire to the indicated lables on the schematic. Don't use the white wire from the controller cable. This wire delivers 5 volt from the NES, we won't need that since we use 5 volt from the arduino.

Once you have completed this you have done the hardest part of this project. All the hardware is done now!

Step 3: Upload the App to Your Android Device

I have made the android app myself with App Inventor. You can download the application directly below to your android device or download the project to tweak something in the code. You can open the project file via the classic App Inventor, not App inventor 2. 

The code of the application is shown above. If the phone detects a motion to the left or right is will tell this via the Bluetooth connection with a byte. If the phone detects the start button is pushed it will send this as well. And the same goes for shaking the phone.

Please feel free to change the code.

Application download link: http://www.4shared.com/mobile/gQbwK7M5/nes.html

Attachments

Step 4: Upload Th Sketch to Your Arduino

Download the sketch from the link below and upload it to your Arduino. Again, feel free to edit the code. The code is also shown here.
The Arduino waits for a byte from the Bluetooth module, if the bytes matches with a button command the arduino will pull that pin low on the 4021 (the NES controller buttons are active low).
 
#include <SoftwareSerial.h>
SoftwareSerial softSerial(4, 11); //RX is on pin 4
int incomingByte = 5;
int A = 8;
int left = 2;
int right = 3;
int start = 7;
void setup() {
  softSerial.begin(9600);
  pinMode(A, OUTPUT);
  digitalWrite(A, HIGH); //buttons are active low
  pinMode(right, OUTPUT);
  digitalWrite(right, HIGH);
  pinMode(left, OUTPUT);
  digitalWrite(left, HIGH);
  pinMode(start,OUTPUT);
  digitalWrite(start,HIGH);
}

void loop() {
if (softSerial.available()) {
  incomingByte = softSerial.read();
  if (incomingByte == 0) {
    digitalWrite(A, LOW);
    delay(500);            //The A button needs a slight delay otherwise it won't be detected by the NES
    digitalWrite(A, HIGH);
  }
    if (incomingByte == 1) {
  digitalWrite(left, HIGH);
  digitalWrite(right, LOW);
  }
    if (incomingByte == 2) {
    digitalWrite(right, HIGH);
    digitalWrite(left, HIGH);
  }
    if (incomingByte == 3) {
      digitalWrite(right, HIGH);
        digitalWrite(left, LOW);
  }
      if (incomingByte == 4) {
        digitalWrite(start, LOW);
        delay(200);              //Same goes for the start button
        digitalWrite(start, HIGH);
  }
}
}

Attachments

Step 5: Hook It Up and Try It Out!

Turn on the arduino, start up the android app on your device, plug your DIY controller into your the NES and play! 
Always turn the bluetooth module on first before you start the android application on your device, otherwise it will not work. And always remember to turn on bluetooth in android before your start the app.  

By tilting the phone to the left or right the d-pad will be pressed to the left/right and by shaking the phone the A button is pressed.

The motion controller will work best with Super Mario Bros. because the game doesn't use up/down on the d-pad, but with a little bit of tweaking in the code other games would work as well.

Post ideas, tips or questions in the comments below. I will try to answer them.