27 lines
492 B
C++
27 lines
492 B
C++
#include <Arduino.h>
|
|
#include <LibPrintf.h>
|
|
#include "joystick.hpp"
|
|
|
|
Joystick joystick;
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
while (!Serial) {
|
|
delay(10);
|
|
}
|
|
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
Serial.println("configured");
|
|
}
|
|
|
|
void loop() {
|
|
double x = joystick.getX();
|
|
double y = joystick.getY();
|
|
bool pressed = joystick.isPressed();
|
|
|
|
printf("X: %.2f | Y: %.2f | Pressed: %s\n", x, y, pressed ? "Yes" : "No");
|
|
|
|
digitalWrite(LED_BUILTIN, pressed ? HIGH : LOW);
|
|
|
|
delay(500);}
|