Outils pour utilisateurs

Outils du site


SNES Controller USB conversion

Project done while I was in Japan
thanks to Tokyo Hackerspace

This small project converts a original SNES controller to act as a HID USB gamepad. This is done using a Arduino Teensy which can fit within the controller.

Note this has already been done before and mostly reply on existing library.

Status

Status du project
Date de début 2016-05
Status Done - working
Initiateur Alexandre

Description

When starting this project I intended to follow this guide on instructables.com.

While the info about the physical SNES controller were useful, I had issue with the code. While a compiled version for the Teensy 2.0 was provided, I did not manage to compile the code. I also realized the “Teensy LC” arduino I planned to use what not one of the build option.

The instructables project code include USB code to make the gamepad appear as a PS3 controller. As I did not care about PS3 support, I realized it made a lot more sense to simply use following:

  1. Arduino Teensy gamepad library
  2. SNES controller library for Arduino

Both library are well documented and only some simple code was needed to get both working together.

On the hardware side, fitting the “Teensy LC” in the SNES controller was quite easy. Note the “Teensy LC” uses a micro USB connector.

As expected, I had to remove some plastic in the SNES controller and slim down The USB cable. The latter was done by removing plastic around the Micro USB connector.

Hardware used

  • Arduino Teensy LC
  • 3m Micro USB cable
  • Original SNES/Super Famicon controller

Step by Step

1. Setup Arduino Teensy environment

  • Follow the guide for the Teensy LC https://www.pjrc.com/teensy/first_use.html
  • You need the Arduino IDE with Teensyduino setup - make sure you can program the Teensy
  • Install the SNESpaduino library (see link in resource bellow)

2. SNES controller

  • Open the SNES controller (standard screws)
  • Remove some plastic from the SNES controller back to make space for the Teensy
  • Cut the Original SNES cable leaving enough length to solder individual cables to the Teensy
  • Solder White cable to the Teensy +5v
  • Solder Brown cable to the Teensy Ground
  • Solder remaining 3 cable to any of the Teensy digital input
  • Slim down the USB cable by removing the plastic around the connector

3. Program Teensy

  • Set teensy as “Keyboard + Mouse + Joystick” (Arduino IDE “Tools” meny)
  • You can use code bellow - simply adapt the SNES controller pin

For more info refer to the SNESpaduino library and example code + Teensy Gamepad example code.

List of resources

Arduino code

 
/* AR - 2016-05 - SNES gamepad to USB using Teensy + SNESpaduino library  
   More info: https://www.posttenebraslab.ch/wiki/electronics/snes_usb/
   Code released under BSD 3-Clause License */

// SNES controller support library
#include <SNESpaduino.h>

// SNES controller pin
#define PIN_LATCH 5   // Orange
#define PIN_CLOCK 1   // Yellow
#define PIN_DATA 3    // Red

// Create a SNESpaduino instance
SNESpaduino pad(PIN_LATCH, PIN_CLOCK, PIN_DATA);

// A variable to store the button-state value
uint16_t btns;

void setup() {

  // configure the joystick to manual send mode
  Joystick.useManualSend(true);
}

void loop() {

  //Get button state using SNES library
  //Note: 12 least significant bit = button state
  btns = pad.getButtons();

  //Set USB gamepad button state
  //Bitwise shift + AND operation to get individual button state
  for (int i=0; i<12; i++) {
    Joystick.button(i+1, (btns >> i) & 1);
  }
  
  // Joystick manual send: transmits everything at once (to USB)
  Joystick.send_now();

  // a brief delay
  delay(1);
 
}
projects/electronics/snes_usb.txt · Dernière modification: 2016/05/11 08:59 par arekkusu