1
0
mirror of https://github.com/pothos/arduino-n64-controller-library synced 2024-12-21 06:38:51 -05:00
Go to file
2020-06-22 21:53:15 +02:00
src Prepare inclusion in Library Manager 2020-06-21 15:11:51 +02:00
library.properties Include search keyword in library.properties description 2020-06-21 19:19:41 +02:00
README.md Correct README 2020-06-22 21:53:15 +02:00

Arduino N64 Controller Library

Based on the work in this guide for using Nintendo controllers with Arduinos here comes a comfortable library for usage with, e.g., Arduino Uno and similar CPUs. For NES there is already nespad. This library uses inline assembly. Controllers can be attached to PIN 0 up to 13. But be aware that it's not written in best way possible. To use it, search for N64 in the Library Manager. Otherwise place the folder N64Controller into your libraries folder or download and import it as ZIP.

I used it in combination with TVout and EEPROM for highscore saving when I modified an existing Tetris port. The port used a Simple Tetris Clone under MIT license and if you want you can see the result here which is quite nice: N64Tetris.

Example code for library usage

#include <N64Controller.h>

N64Controller player1 (12); // this controller for player one is on PIN 12

void setup() {
    player1.begin(); // Initialisation
}

void loop() {
    delay(30);
    player1.update(); // read key state
    if (player1.A() && player1.D_down()
        || player1.Start()) { // has no deeper meaning ;)
        int xaxis = player1.axis_x(); // can be negative oder positive
                                   // regarding to orientation of the analog stick
    }
    // …
}

Wireing

To use, hook up the following to the Arduino:

  • Digital I/O PIN specified as parameter (2 is fallback if you specify a number > 13): Connect to middle N64 controler PIN for serial/signal line
  • Grounding GND: Connect to left N64 controller PIN
  • Power line 3.3V: Connect to right N64 controller PIN
   /------------\
  / O    O     O \
 | GND Signl 3.3V |
 |________________|

Maybe: connect PIN X with external 1K pull-up resistor to the 3.3V rail

Authors

  • Gamecube controller to Nintendo 64 adapter by Andrew Brown
  • Rewritten for N64 to HID by Peter Den Hartog
  • Modified to be a library with selectable pins by Kai Lüke