0

I have some dead simple code for reading the x and y analog values from my Arduino joystick module. It works fine on my Arduino Mega 2560, but Adafruit Feather nRF52832 reads the analog signal completely incorrectly.

const int x_pin = 4;
const int y_pin = 3;
int x = 0;
int y = 0;
void setup() {
  Serial.begin(115200);
}

void loop() {
  x = analogRead(x_pin);
  y = analogRead(y_pin);
  Serial.println(String(x) + ", " + String(y));
  delay(250);
}

When I run this with my Arduino Mega, I have no issues and the output is read as expected. Watch the video here. As you can see, each axis is read invidually and they go from 0->1023.

However, with the same setup and same code but just with the Adafruit Feather, the data is completely nonsensical. Watch the video here. Left and up axes are ignored while the right and down axes affect both when they should only affect one. The data points also start out at ~60 and only go to ~200.

The wiring for both setups is the same, the code is also unchanged. Both recieve 5v power from the Arduino.

  • 5v on the joystick is connected to 5V on the Arduino
  • GND on the joystick is connected to GND on the Arduino
  • VRx on the joystick is connected to A4 on the Arduino/Adafruit
  • VRy on the joystick is connected to A3 on the Arduino/Adafruit

I don't think a wiring diagram is necessary for how simple the circuit is. The connections on the Adafruit board have been soldered to ensure proper connection.

Can you please help me figure out what's going on with my Adafruit board and get the analog signal read properly?

Jeff Chen
  • 111
  • 2
  • 1
    Wiring diagram is always helpful. – DamienD Mar 24 '22 at 04:31
  • 2
    One thing that comes to mind is that the Feather analog inputs are limited to 3.6V. They may have been damaged by the 5V signal. – DamienD Mar 24 '22 at 04:32
  • Thanks @DamienD! Factory resetting the board allowed the analog pins to work almost as intended, so your hunch was right. However, when maxing the joystick module out the analog value would wrap back around, and after reading your comment I realized that it was because it was taking in 5v but expecting 3v3. Now it's working perfectly. Do you know why the joystick module would be labelled 5V when it works fine even on 3V? – Jeff Chen Mar 24 '22 at 04:57
  • the module doesn't really care what the actual voltage is, but they had to label it with something. – Kartman Mar 24 '22 at 09:37

0 Answers0