My tutorial on building a bluetooth SNES controller - RKD 

   The goal of this tutorial is to provide the instruction necessary to build a bluetooth super nintendo controller that can be used with any Android device. In order to successfully complete the entire tutorial you will probably need some soldering skills, basic circuits knowledge, and some C++ and Java programming experience.

   Before we can actually start the tutorial we will need some basic background knowledge about the super nintendo controller. The device is surprisingly simple, and after a little experimenting can be easily manipulated. Basically, there are 3 wires that we are concerned with: Data, Clock, and Latch. In order for the super nintendo entertainment system to get data from the controller it pulses the latch line every 16ms. On each pulse the controller knows to send the current button status (via 2 bytes of data). If a button is being pressed its corresponding bit in the data bytes will be 0, otherwise it will be 1. For example, if only the B button is being pressed the controller will send 0111111111111111. Or if only the Y button is being pressed it will send 1011111111111111. If both buttons are being pressed it will send 0011111111111111, and so on... These data bytes are sent out the data line, and synchronized with the clock line. This means that after the latch line pulse there will be 16 clock line pules. After each clock line pulse one data bit is read from the data line until all 16 bits (or 2 bytes) have been obtained. The only exception is the first bit, which will need to be read right after the latch line drops, and before the first clock pulse.


Pin Description Wire Color
1 +5v White
2 Data Clock Yellow
3 Data Latch Orange
4 Serial Data Red
5 N/C -
6 N/C -
7 Ground Brown
Clock Cycle Button Reported
1 B
2 Y
3 Select
4 Start
5 Up on joypad
6 Down on joypad
7 Left on joypad
8 Right on joypad
9 A
10 X
11 L
12 R
13-16 none (always high)

For more info on controller protocol click here

   Another important protocol to understand is SPP(Serial Port Profile). The typical bluetooth connection uses this profile to transmit and recieve data. Basically, once the bluetooth connection is established, a specific COM port within the connecting device will be used for data communication. Although its not neccessary for this tutorial, a great way to learn the basics of SPP is to experiment with RS232 connections.

Check out my RS232 PC application interfaced with the SNES controller here

   Now that we have some knowledge of how the controller works we can begin building. To build this device we will need a BlueSMiRF Gold Bluetooth Modem, an Arduino Pro Mini 328, a usb connector for the Arduino (although I built my own using a MAX232 chip, an RS232 to TTL converter, and an RS232 to USB adapter), some form of 5V power supply, and a standard super nintendo controller. The Arduino will be programmed to hit the latch line every 16ms, and then strobe the clock line 16 times and retrieve the data. This data will then be sent out the transmit(tx) line of the arduino and into the recieve(rx) line of the BlueSMiRF. If the BlueSMiRF is paired with a device (say an Android phone) it will be as if the data is going into the recieve line of this device. But before we can start communication between devices we need to first program the Arduino.

   First, download the Arduino IDE. Next, download the MeetAndroid library for Arduino. Start the Arduino IDE, it should automatically open a blank file. Copy the code from here and paste it into the blank file. Next, we will need to add the MeetAndroid library to the sketch folder. Navigate to your sketch folder (CMD + K) and add a libraries subdirectory. Place the MeedAndroid library here. Now save and restart the Arduino IDE. Open the saved project back up and now import the MeetAndroid library.




   To program this code to the Arduino, select the Arduino Pro Mini 328 (3.3V/8Mhz) from the tools -> board menu. Before you can select the serial port from the tools menu you will need to plug in your Arduino adapter (this will require soldering header pins to the top 6 arduino ports(BLK - GRN)). Once it is plugged in, select the port used to program from tools -> serial port (It should be something like tty.*whatever your usb device is*). Next, you can compile the code by pressing the play button, and if it compiles properly it is ready to upload.

   Now that the Arduino is ready to go we need to prepare the BlueSMiRF for Android communication. The only real preparation that needs to be done is resetting the BAUD rate to 57600, but I also like to change the name of my Bluetooth module to something like SNES Controller. First, download some sort of terminal emulator, I personally like Zterm for my Mac (you could use the terminal, but emulators are actually easier for this sort of thing). Before you can configure your Bluetooth Molule you will also need to make sure it is paired and connected with your computer. Make sure the Bluetooth module is turned on (has VCC and GND connected, again will require soldering header pins). The PC side is fairly self explanatory in both Windows and Mac, just go to your Bluetooth settings and add a new device. When it asks for a pairing code enter "1234". Once connected open up Zterm and go to Settings->Modem Preferences and select the module (should be called Firefly).




   Next, go to Settings->Connection and set the BAUD rate to 115200 (as this is the default on the BlueSMiRF). Restart both Zterm and the BlueSMiRF, once the BlueSMiRF is powered on again you have 60 seconds to enter config mode. To do this you need to hit Command+K once Zterm starts, a small text box should then appear. In this text box enter "$$$", it should reply with "CMD?" and you will need to enter "SU,57600" to set the chip BAUD rate. It should reply with "AOK", now just enter "---" and the chip is configured for Android communication.


If you would like to get fancy with the Bluetooth configuration the RN-41 AT command set can be found here

   Now it is time to connect everything together. This process can get very tangled and messy, so it is a good idea to try to maintain organization in any way possible (I used cardboard and zip ties). As far as connections between the components go see the diagram below.

BlueSMiRF Rx <--> Arduino Tx
BlueSMiRF Tx <--> Arduino Rx
BlueSMiRF CTS <--> BlueSMiRF RTS
SNES Latch line <--> Arduino Pin 2
SNES Clock line <--> Arduino Pin 3
SNES Data line <--> Arduino Pin 4

Other than that all VCC and GND lines go to +5V and GND, respectively.