URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       Arti-X Forums
  HTML https://artixsoft.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Arduino Tutorials
       *****************************************************
       #Post#: 32--------------------------------------------------
       [TUTORIAL]How To Add A SNES Controller To Your Arduino
       Projects[TUTORIAL]
   DIR By: Artix
       Date: December 9, 2014, 8:43 pm
       ---------------------------------------------------------
       Hello! Scott here, and today, we will be getting your Arduino to
       recognize your old SNES controller! From this tutorial, you can
       use your SNES controller to control your Arduino projects, from
       servos, to LEDs. Lets get started!
       Parts\Software Needed needed:
       SNESpaduino-master Library
       DOWNLOAD:
  HTML http://www.mediafire.com/download/9a7kcpxw8pspf8s/SNESpaduino-master.zip
  HTML http://www.mediafire.com/download/9a7kcpxw8pspf8s/SNESpaduino-master.zip
       USB Cable
       Arduino
       Jumper Wires
       Breadboard (optional)
       SNES Controller
       So to begin, grab your SNES controller, and you will need to
       take your jumper wires, and plug them into the correct holes in
       the controllers plug. Heres the layout:
       [IMG]
  HTML http://i57.tinypic.com/2h4eqvo.jpg[/img]
       Once you have done that, you will have your wires sticking our
       of your controllers plug. Mine looks like this:
       [IMG]
  HTML http://i58.tinypic.com/104eu7k.jpg[/img]
       3 of those wires will go into pins 2, 3, and 4, and 2 of them
       are for V+ and GND. Plug them in according to this chart:
       STROBE - Digital 2
       CLOCK - Digital 3
       DATA - Digital 4
       +5V - +5V
       GND - GND
       Mine looks like this:
       [IMG]
  HTML http://i57.tinypic.com/14sz2md.jpg[/img]
       [IMG]
  HTML http://i61.tinypic.com/vmy6wk.jpg[/img]
       Once everything is set up, make sure you have SNES library
       provided above installed. If you dont know how to install it,
       use this guide:
  HTML http://arduino.cc/en/Guide/Libraries
       Open the Arduino IDE and paste this code in:
       --- Code ---
       
       #include <SNESpaduino.h>
       
       //You may need to change the pin lineup if your controller
       isnt working - Scott
       SNESpaduino pad(2, 3, 4 );
       
       
       uint16_t btns;
       
       void setup()
       {
       Serial.begin(9600);
       }
       
       void loop()
       {
       
       btns = pad.getButtons();
       
       if(btns & BTN_A)
       Serial.println("A");
       
       if(btns & BTN_X)
       Serial.println("X");
       
       if(btns & BTN_Y)
       Serial.println("Y");
       
       if(btns & BTN_B)
       Serial.println("B");
       
       if(btns & BTN_DOWN)
       Serial.println("Down");
       
       if(btns & BTN_UP)
       Serial.println("Up");
       
       if(btns & BTN_LEFT)
       Serial.println("Left");
       
       if(btns & BTN_RIGHT)
       Serial.println("Right");
       
       if(btns & BTN_L)
       Serial.println("Left Trigger");
       
       if(btns & BTN_R)
       Serial.println("Right Trigger");
       
       if(btns & BTN_SELECT)
       Serial.println("Select");
       
       if(btns & BTN_START)
       Serial.println("Start");
       
       delay(100);
       }
       --- End Code ---
       Upload the code, and open your serial monitor in the Arduino
       IDE, and start pressing some buttons to see if it all worked.
       You should get this:
       [IMG]
  HTML http://i62.tinypic.com/vxf2ab.jpg[/img]
       From the code above, you can modify it to your liking to preform
       whatever you want it to do!
       Thank you for reading! Post any questions, or your go at this
       project.
       *****************************************************
       Page 1 of 1