Skip to content

Instantly share code, notes, and snippets.

@konsumer
Last active May 18, 2020 06:52
Show Gist options
  • Select an option

  • Save konsumer/a00fab0cdaed3298aafedb429de766f1 to your computer and use it in GitHub Desktop.

Select an option

Save konsumer/a00fab0cdaed3298aafedb429de766f1 to your computer and use it in GitHub Desktop.
// attach gamecube controller red wire on this digital pin
#define GC_PIN 7
#include "Nintendo.h"
CGamecubeController GamecubeController(GC_PIN);
// attach gates to these digital-out pins
// these also happen to be the PWM-able pins on the arduino nano
int pins[6] = { 3, 5, 6, 9, 10, 11 };
void setup() {
for (int i = 0; i < 6; i++) {
pinMode(pins[i], OUTPUT);
}
}
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++) {
digitalWrite(pins[i], buttonsNow[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment