- ファミコンのコントローラー(Iコン)
- ATmega32U4 Pro micro Arduino互換ボード
- USBケーブル
- 基板の右上のピン -> ArduinoのVCC
- 基板の右上から4つ目のピン -> ArduinoのGND
- ICの1番ピン(ICの足の一番右下) -> arduinoのIO9
- ICの4番ピン(右下から左へ4つめ) -> arduinoのIO2
- ICの5番ピン -> arduinoのIO3
- ICの6番ピン -> arduinoのIO5
- ICの7番ピン -> arduinoのIO4
- ICの13番ピン(ICの足の右上から左へ4つめ) -> arduinoのIO7
- ICの14番ピン -> arduinoのIO6
- ICの15番ピン -> arduinoのIO8
#include <Joystick.h> Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD, 4, 0, // Button Count, Hat Switch Count true, true, false, // X and Y, but no Z Axis false, false, false, // No Rx, Ry, or Rz false, false, // No rudder or throttle false, false, false); // No accelerator, brake, or steering void setup() { // Initialize Button Pins pinMode(2, INPUT_PULLUP); pinMode(3, INPUT_PULLUP); pinMode(4, INPUT_PULLUP); pinMode(5, INPUT_PULLUP); pinMode(6, INPUT_PULLUP); pinMode(7, INPUT_PULLUP); pinMode(8, INPUT_PULLUP); pinMode(9, INPUT_PULLUP); // Initialize Joystick Library Joystick.begin(); Joystick.setXAxisRange(-1, 1); Joystick.setYAxisRange(-1, 1); Joystick.setYAxis(0); Joystick.setXAxis(0); Joystick.setButton(0, 0); Joystick.setButton(1, 0); Joystick.setButton(2, 0); Joystick.setButton(3, 0); } // Last state of the buttons int lastButtonState[8] = {0,0,0,0,0,0,0,0}; void loop() { // Read pin values for (int index = 0; index < 8; index++) { int currentButtonState = !digitalRead(index + 2); if (currentButtonState != lastButtonState[index]) { switch (index) { case 0: // UP if (currentButtonState == 1) { Joystick.setYAxis(-1); } else { Joystick.setYAxis(0); } break; case 1: // DOWN if (currentButtonState == 1) { Joystick.setYAxis(1); } else { Joystick.setYAxis(0); } break; case 2: // RIGHT if (currentButtonState == 1) { Joystick.setXAxis(1); } else { Joystick.setXAxis(0); } break; case 3: // LEFT if (currentButtonState == 1) { Joystick.setXAxis(-1); } else { Joystick.setXAxis(0); } break; case 4: // FIRE1 Joystick.setButton(0, currentButtonState); break; case 5: // FIRE2 Joystick.setButton(1, currentButtonState); break; case 6: // FIRE3 Joystick.setButton(2, currentButtonState); break; case 7: // FIRE4 Joystick.setButton(3, currentButtonState); break; } lastButtonState[index] = currentButtonState; } } delay(10); }
簡単なので、ファミコンエミュレータで遊ばれている方には、お勧めの改造です。
ファミコンコントローラUSB化のキットにしました。とても簡単にUSB化できます。こちら👇👇で販売しています。
















コメント