arduino-n64-controller-library/README.md

53 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2017-05-14 07:19:22 -04:00
# Arduino N64 Controller Library
2020-06-22 15:46:58 -04:00
Based on the work in [this guide for using Nintendo controllers with Arduinos](http://www.instructables.com/id/Use-an-Arduino-with-an-N64-controller/) here comes a comfortable library for usage with, e.g., Arduino Uno and similar CPUs. For NES there is already [nespad](http://code.google.com/p/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.
2020-06-22 15:46:58 -04:00
I used it in combination with [TVout](http://code.google.com/p/arduino-tvout/) and [EEPROM](http://arduino.cc/playground/Code/EEPROMWriteAnything) 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](http://pothos.blogsport.eu/files/2012/03/N64Tetris.zip).
2017-05-14 07:19:22 -04:00
## Example code for library usage
2017-05-14 07:19:22 -04:00
```cpp
#include <N64Controller.h>
2017-05-14 07:19:22 -04:00
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
2020-06-22 15:53:15 -04:00
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
}
// …
}
2017-05-14 07:19:22 -04:00
```
2017-05-14 07:19:22 -04:00
## Wireing
To use, hook up the following to the Arduino:
2020-06-22 15:46:58 -04:00
2020-06-22 15:49:27 -04:00
* 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
2020-06-22 15:46:58 -04:00
* Grounding GND: Connect to left N64 controller PIN
* Power line 3.3V: Connect to right N64 controller PIN
2017-05-14 07:19:22 -04:00
```
/------------\
/ O O O \
| GND Signl 3.3V |
|________________|
2017-05-14 07:19:22 -04:00
```
Maybe: connect PIN X with external 1K pull-up resistor to the 3.3V rail
2017-05-14 07:19:22 -04:00
## Authors
2020-06-22 15:46:58 -04:00
* Gamecube controller to Nintendo 64 adapter by Andrew Brown
2017-05-14 07:26:24 -04:00
* Rewritten for N64 to HID by Peter Den Hartog
* Modified to be a library with selectable pins by Kai Lüke