42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
int const UP_BTN = 2;
|
|
int const DOWN_BTN = 4;
|
|
int const LEFT_BTN = 5;
|
|
int const RIGHT_BTN = 3;
|
|
int const E_BTN = 6;
|
|
int const F_BTN = 7;
|
|
int const JOYSTICK_BTN = 8;
|
|
int const JOYSTICK_AXIS_X = A0;
|
|
int const JOYSTICK_AXIS_Y = A1;
|
|
int buttons[] = {UP_BTN, DOWN_BTN, LEFT_BTN, RIGHT_BTN, E_BTN, F_BTN, JOYSTICK_BTN};
|
|
int line = 1;
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
Serial.println("Serial Started");
|
|
for (int i=0; i < 7; i++) pinMode(buttons[i], INPUT_PULLUP);
|
|
Serial.println("Finished pin setup");
|
|
delay(2000);
|
|
}
|
|
|
|
void loop() {
|
|
Serial.print(line);
|
|
Serial.print(". Yeet!\n");
|
|
|
|
Serial.print("UP="),Serial.println(digitalRead(UP_BTN));
|
|
Serial.print("DOWN="),Serial.println(digitalRead(DOWN_BTN));
|
|
Serial.print("LEFT="),Serial.println(digitalRead(LEFT_BTN));
|
|
Serial.print("RIGHT="),Serial.println(digitalRead(RIGHT_BTN));
|
|
Serial.print("E="),Serial.println(digitalRead(E_BTN));
|
|
Serial.print("F="),Serial.println(digitalRead(F_BTN));
|
|
Serial.print("JOYSTICK BTN="),Serial.println(digitalRead(JOYSTICK_BTN));
|
|
|
|
// Joystick range is from 0 to 653 +- 1
|
|
// Center is about 323 +- 2. A deadzone of 10 or 20 should be safe.
|
|
Serial.print("X: ");
|
|
Serial.println(analogRead(JOYSTICK_AXIS_X));
|
|
Serial.print("Y: ");
|
|
Serial.println(analogRead(JOYSTICK_AXIS_Y));
|
|
line++;
|
|
delay(150);
|
|
}
|