Post subject: Emulating a SNES controller with Arduino Uno?
Joined: 9/2/2017
Posts: 1
Location: Toronto
I've been trying to figure this out off and on for about a week and I feel like I'm having some kind of fundamental misunderstanding about how SNES hardware works. The problem: I speedrun a category of Super Mario RPG that requires getting a certain item. To get this item you must play a minigame where you select either left or right on the dpad. The correct one is random every time. You must win 100 times cumulatively. This is really, really boring to watch. I would like to configure my setup so that chat input determines which of the two directions are chosen (Twitch Plays Pokemon style). However, I need to control the game between trials, as between each minigame attempt there is required mashing and menuing. I speedrun on a console. What I've tried to do: I bought a SNES extension cord and opened up the input port to figure out which wires are which. I cut the cord and re-connected its internal wires to each other via a breadboard, except for the data wire. (First I plugged a controller into this contraption and plugged the other end into my SNES to make sure the cable isn't faulty.) I have a NintendoSpy input display connected to my super famicom and breadboard output for troubleshooting. I'm testing inputs on my super famicom by opening up the Super Game Boy menu and seeing what the cursor does. At first, I connected the breadboard to digital port 9 on my arduino and ran the following code:
void loop() {
    analogWrite(9, B00111011);
}
(i tried a whole bunch of values other than B00111011 as well, but you get the idea) My super famicom responded to this, but it seemed to be pressing random buttons in short bursts. The SGB cursor was moving around a few pixels and opening/closing submenus. Looking at NintendoSpy confirmed this, this code seems to make it push every button on the controller erratically. I then found this library, which accepts inputs into the arduino digital ports and outputs them to a snes console: https://github.com/jtrinklein/SConE/tree/master/src The author claims this code works, but I haven't been able to get it to fully work. I connected the data/latch/clock wires to the designated analog ports in this code, and adapted the code a bit by replacing the state of the digital inputs with hard-coded values to output an A press: https://pastebin.com/57zXm3H8 I'm running this on my arduino right now (i also recently added some code that toggles the A button every second to simulate repeated pressing, but that's not important). NintendoSpy is picking up the input and showing that it is indeed an A press and nothing else. However nothing is happening on my SFC, no menus are being opened despite the cursor being over one, etc. I also tried with a d-pad input instead of the A button but the cursor wouldn't move. I suspect that this is due to the Arduino's clock speed, but I'm not sure how to adjust that. So I had 2 sets of code, one of which the SNES picked up but it was the wrong input, and one of which was the right input but the SNES won't do anything with. Long term all I would really like to do is write code that reads Twitch IRC input and outputs a left or a right D-pad input according to that, and have a switch on the breadboard that toggles whether the Arduino output or the actual controller output is being sent to the SNES. I thought I could accomplish this by just creating a circuit that switches which data wire goes to the cord connected to my sfc. I've reached out to some others who have worked on similar projects before but have not received a response yet, and was wondering if anyone in this forum might be willing to impart some knowledge that could help me solve this. (I also don't own an oscilloscope.) Thank you!