Arduino Leonardo Wing Flaps

Any issues, problems or troubleshooting topics related to computer hardware and the Prepar3D client application
Post Reply
SimGuy
Posts: 1
Joined: Fri Sep 30, 2022 2:49 pm

Arduino Leonardo Wing Flaps

Post by SimGuy »

I am running into an issue regarding integration of a fabricated wing flaps lever. I am using a linear potentiometer which is connected to an Arduino Leonardo using a joystick library so that P3D can recognize it as a controller. The problem is that when I am attempting to change the controls for the controller, it is reading it automatically as a Y axis controller, which then overrides the Elevator axis default.

I attempted to change the value to Z axis as it is not used in any P3D axis assignments, but it seems that P3D only accepts Rz axis values which is assigned to the Rudder. Is there any known way to work around this without overriding the Y axis on the Elevator? I am implementing a Yoke controller as well which is obviously more important to functionality than the wing flaps slider.

Here is the code for the Arduino currently:

Code: Select all

#include "Joystick.h"

// 2 Buttons, No hats, X and Y axis, no Z axis, Rx, Ry, Rz, Rudder, Throttle, Brake, or Steering
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK, 0, 0, false, true, false, false, false, false, false, false, false, false, false);

void setup() {


    pinMode(A0, INPUT); //initialize potentiometer pin


    Joystick.begin();
    Joystick.setYAxisRange(321, 702); //range of potentiometer
}

void loop() {

    // Y-Axis
    int YAxis = analogRead(A0);
    Joystick.setYAxis(YAxis);
   // Serial.println(yAxis);
    delay(50);

}
patrickibarra
Posts: 4
Joined: Tue Oct 03, 2023 4:57 am

Re: Arduino Leonardo Wing Flaps

Post by patrickibarra »

Hello, I think you can try using the "Rz" (rudder) axis for your wing flaps lever instead of the "Y" axis. Although the "Rz" axis is assigned to the rudder by default, you can override this assignment by remapping it to the wing flaps control in P3D.
patrickibarra
Posts: 4
Joined: Tue Oct 03, 2023 4:57 am

Re: Arduino Leonardo Wing Flaps

Post by patrickibarra »

Moreover, by assigning the "Rz" axis to the wing flaps control, you should be able to use your fabricated wing flaps lever without overriding the "Y" axis assignment for the yoke controller.
Hope that it is useful for you
Post Reply