feat: add joystick demo
This commit is contained in:
+12
-7
@@ -1,4 +1,8 @@
|
||||
#include <Arduino.h>
|
||||
#include <LibPrintf.h>
|
||||
#include "joystick.hpp"
|
||||
|
||||
Joystick joystick;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
@@ -11,11 +15,12 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("ping");
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
delay(1000);
|
||||
double x = joystick.getX();
|
||||
double y = joystick.getY();
|
||||
bool pressed = joystick.isPressed();
|
||||
|
||||
Serial.println("pong");
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
delay(1000);
|
||||
}
|
||||
printf("X: %.2f | Y: %.2f | Pressed: %s\n", x, y, pressed ? "Yes" : "No");
|
||||
|
||||
digitalWrite(LED_BUILTIN, pressed ? HIGH : LOW);
|
||||
|
||||
delay(500);}
|
||||
|
||||
Reference in New Issue
Block a user