#include <Joystick.h>
// Define the joystick
Joystick_ Joystick;
// Define the potentiometer pin
const int potPin = A0;
void setup() {
// Initialize the joystick
Joystick.begin();
Joystick.setJoystickRange(0, 1023); // Adjust range as needed
}
void loop() {
// Read the potentiometer value
int potValue = analogRead(potPin);
// Map the value to a joystick axis (e.g., X-axis)
Joystick.setJoystickXAxis(map(potValue, 0, 1023, -512, 512));
delay(50); // Update rate
}