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