Skip to content

Instantly share code, notes, and snippets.

@konsumer
Last active May 20, 2020 00:12
Show Gist options
  • Save konsumer/a856c3975d4c8d8bb5f05efea37b04e2 to your computer and use it in GitHub Desktop.
Save konsumer/a856c3975d4c8d8bb5f05efea37b04e2 to your computer and use it in GitHub Desktop.
Gamecube controller (or DDR Mat) to USB MIDI. Install "Nintendo" and "MIDIUSB" in arduino library-manager. Use this on a programmable-USB arduino, like Leonardo.
#include "Nintendo.h"
#include "MIDIUSB.h"
// attach gamecube controller red wire on this digital pin
#define GC_PIN 7
// MIDI controls for each pad
int ctrls[6] = { 10, 11, 12, 13, 14, 15 };
CGamecubeController GamecubeController(GC_PIN);
void controlChange(byte channel, byte control, byte value) {
midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
MidiUSB.sendMIDI(event);
}
void setup() {}
void loop() {
auto report = GamecubeController.getReport();
boolean buttonsNow[6] = {
report.dup,
report.ddown,
report.dleft,
report.dright,
report.a,
report.b
};
for (int i = 0; i < 6; i++) {
controlChange(1, ctrls[i], buttonsNow[i] ? 127 : 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment