This program uses a NUCLEO-F401RE to control an SNES console by sending the button states. (1 = Unpressed, 0 = Pressed) Data, Clock and Latch from the SNES must be connected to the appropriate pins. The NUCLEO is powered by the SNES through E5V. The power jumper should be moved to E5V configuration when powered by SNES.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kyancey
Date:
Thu Oct 05 14:43:56 2017 +0000
Child:
1:2a346daf070f
Commit message:
Controls SNES Controller. Sends repeated signal: A, Nothing, A, Nothing, etc.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 05 14:43:56 2017 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+
+
+DigitalOut Data(D2);
+DigitalIn Latch(D3);
+DigitalIn Clock(D4);
+
+void waitUntilHigh(DigitalIn x)
+{
+    while(x != 1) {};
+}
+
+void waitUntilLow(DigitalIn x)
+{
+    while(x == 1) {};
+}
+
+void sendButton(int button)
+{
+    Data = button;
+    waitUntilLow(Clock);
+    waitUntilHigh(Clock);
+}
+
+void sendButtonsPressed(int b, int y, int select, int start,
+                        int up, int down, int left, int right,
+                        int a, int x, int l1, int r1)
+{
+    Data = 1;
+    waitUntilHigh(Latch);
+    waitUntilLow(Latch);
+
+    sendButton(b);
+    sendButton(y);
+    sendButton(select);
+    sendButton(start);
+    sendButton(up);
+    sendButton(down);
+    sendButton(left);
+    sendButton(right);
+    sendButton(a);
+    sendButton(x);
+    sendButton(l1);
+    sendButton(r1);
+}
+
+int main()
+{
+    while(1) {
+        sendButtonsPressed(1, 1, 1, 1,      //b,y,select,start
+                           1, 1, 1, 1,     //up,down,left,right
+                           0, 1, 1, 1);    //a,x,l1,r1
+
+        sendButtonsPressed(1, 1, 1, 1,      //b,y,select,start
+                           1, 1, 1, 1,     //up,down,left,right
+                           1, 1, 1, 1);    //a,x,l1,r1
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 05 14:43:56 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/235179ab3f27
\ No newline at end of file