Problems with Potentiometer

Hi, Im trying to repurpose the rudder pedals from an Logitech G940 that have an 10K/50 Potentiometer in them. I'm using an Arduino Micro to get the analog output and convert it to an digital HID.

I just want one axis so I made this code using JoystickLibrary2.0

#include <Joystick.h>

//Define input pins
#define joyRz A0

//Joystick(Joystick HID ID, Joystick Type, Button count, Hat switch count, Include X, Include Y
//Include Z, Include Rx, Include Ry, Include RZ, Include Rudder, Include Throttle, Include Accelorator,
//Include Brake, Include steering

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 0, 0, false, false, false, false, false, true, false, false, false, false, false);

const bool initAutoSendState = true;

int rzAxis_ = 0;

void setup() {

// put your setup code here, to run once:

Joystick.begin();
}

void loop() {
// put your main code here, to run repeatedly:

rzAxis_ = analogRead(joyRz);
#include <Joystick.h>

//Define input pins
#define joyRz A0

//Joystick(Joystick HID ID, Joystick Type, Button count, Hat switch count, Include X, Include Y
//Include Z, Include Rx, Include Ry, Include RZ, Include Rudder, Include Throttle, Include Accelorator,
//Include Brake, Include steering

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 0, 0, false, false, false, false, false, true, false, false, false, false, false);

const bool initAutoSendState = true;

int rzAxis_ = 0;

void setup() {
// put your setup code here, to run once:

Joystick.begin();
}

void loop() {
// put your main code here, to run repeatedly:
rzAxis_ = analogRead(joyRz);

delay(10);
}

My problem is that nothing works.

I have wired my pot as Ground to Ground, Signal to A0 and 5v to 5v.
but nothing works. If i run a sketch which just send the signal to the serial monitor it only changes from 132 to 135.

I also tried it with an "normal" 10k Pot too and it didn't work with that either.

Might I have two broken Potentiometers ? Or is the code not working?

Appreciate all the help I can get.

You mean that nothing compiles? Either things went wron when you copied to the forum or your code is really a mess with multiple setup() functions and multiple loop() functions.

Please take some time to read https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966; next edit your post and post the code using code tags.

How is rzAxis_ automagically associated with your Joystick object?

Please post the entire sketch, as-is, in code-tags - what I see is multiple setup()'s and multiple loop()'s which obviously won't compile.

We ask you to post your code complete is so we can actually compile and run it, so just providing snippets isn't useful.

Hi, @denkasan
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Can you post your simple sketch and post a picture of your project connected to the pot?

If you just connect the analog input to gnd and then to 5V, what data readings do you get?

Do you have a DMM to measure some voltages?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia: