Kannst Du ausschliessen, das der Anlaog-PIN in der Luft hängt?
Grundsätzlich erstmal debuggen um zu sehen, was da eigentlich tatsächlich an Werten rum kommt.
Mach mal den Code - kopier aus dem SerMon raus und hier in CodeTags wieder rein.
Mal sehen, was bei rum kommt.
#include <Joystick.h>
// USB Rudder-Pedals
// NOTE: This sketch file is for use with Arduino Leonardo and
// Arduino Micro only.
//------------------------------------------------------------
//change these to define which pins your hall effect sensors or potentiometers are connected.
const byte R_PIN = A0;
const byte T_PIN = A1;
//change these to change trim and limits. Calibrating your joystick in Windows achieves the same thing
int R_MIN = 0;
int R_MAX = 1023;
int R_TRIM = 0;
int R_INVERT = 1;
int T_MIN = 0;
int T_MAX = 1023;
int T_TRIM = 0;
int T_INVERT = 1;
#include <Joystick.h>
Joystick_ Joystick(0x04, JOYSTICK_TYPE_JOYSTICK,
0, 0, // Button Count, Hat Switch Count
false, false, false, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
true, true, // Yes rudder, yes throttle
false, false, false); // No accelerator, brake, or steering
void setup()
{
Serial.begin(115200);
Serial.println(F("Start"));
// Initialize Joystick Library
Joystick.begin(true); //false = dont send automatically. We will sendState() at the end of the loop
Joystick.setRudderRange(-512, 512);
Joystick.setThrottleRange(-512, 512);
}
void loop()
{
unsigned int analogWert = analogRead(R_PIN);
//read analog axes
int value = map(analogWert + R_TRIM , R_MIN, R_MAX, -512, 512) * R_INVERT;
Joystick.setRudder(value);
Serial.print(F("r: "));
Serial.print(analogWert);
Serial.print("\t");
Serial.println(value);
analogWert = analogRead(R_PIN);
value = map(analogRead(T_PIN) + T_TRIM , T_MIN, T_MAX, -512, 512) * T_INVERT;
Joystick.setThrottle(value);
Serial.print(F("t: "));
Serial.print(analogWert);
Serial.print("\t");
Serial.println(value);
Joystick.sendState();
delay(5);
}