Help with Joystick Values

I'm new to Arduinos and I've been trying to get an input from a joystick. I've got it all wired up but the values are just not right one bit.

The switch is working fine, but the X and Y axis's are far from that. The centre of the x and y axis is usually around 770-810, which flickers around 1-2 numbers from the centre (to be expected). The problem is that it should be 512 and when I push it up to full positive axis (same for both axis) it will be around the 1023 (somewhat normal), but full negative is 0-3. I've been looking around the joystick for anything that I could use to calibrate the centre, but theres nothing.

I've tried 4 different sticks and they all have the same problem so the only other thing I could think of is the cables. I've also looked at calibration code from other users but I've had no success.

(writing from another user that I copied)

(basic code to read the values)

// Arduino pin numbers
const int SW_pin = 0; // digital pin connected to switch output
const int X_pin = A0; // analog pin connected to X output
const int Y_pin = A1; // analog pin connected to Y output

void setup() {
  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  Serial.begin(9600);
}

void loop() {
  Serial.print("Switch:  ");
  Serial.print(digitalRead(SW_pin));
  Serial.print(" | ");
  Serial.print("X-axis: ");
  Serial.print(analogRead(X_pin));
  Serial.print(" | ");
  Serial.print("Y-axis: ");
  Serial.print(analogRead(Y_pin));
  Serial.println(" | ");
  delay(200);
}

Any help is nice

Post links to technical information on your stick, there are a lot of them to look at and I do not know which one. Be sure it shows a schematic of how it is assembled.

What voltage do you have if you measure between GND and VCC

There a a couple of versions of pro mini 16 MHz, 5 v and a 3.3v 8 MHz which version do you have ?
The counts you are seeing kind of suggests you are using a 3.3 volt device with 5 volts.

The picture has an ATmega32u4 which is 5v 16MHz and if the voltage across GND and VCC is less than 5v it may require a shorting of j1, I don't have a pro micro so I can't say that and be 100% sure. So a good place to start is to look into how your voltage regulator can be configured for your board version.


This is a photo of the setup, I have multiple other arduinos I can use. I have it plugged into a 5v port.

Edit - fixed it by plugging power into VCC instead of 5V

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.