-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathN64Simplified.ino
More file actions
21 lines (18 loc) · 829 Bytes
/
Copy pathN64Simplified.ino
File metadata and controls
21 lines (18 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <N64Controller.h>
N64Controller player1 (2); // this controller for player one is on PIN 12
void setup() {
Serial.begin(115200);
player1.begin(); // Initialisation
}
void loop() {
player1.update(); // read key state
uint8_t firstByte = (player1.A() << 7) | (player1.B() << 6) | (player1.Z() << 5) | (player1.Start() << 4) | (player1.D_up() << 3) | (player1.D_down() << 2) | (player1.D_left() << 1) | player1.D_right();
uint8_t secondByte = (player1.L() << 5) | (player1.R() << 4) | (player1.C_up() << 3) | (player1.C_down() << 2) | (player1.C_left() << 1) | player1.C_right();
uint8_t thirdByte = player1.axis_x();
uint8_t fourthByte = player1.axis_y();
Serial.write(firstByte);
Serial.write(secondByte);
Serial.write(thirdByte);
Serial.write(fourthByte);
delay(10);
}