Analog Joystick Not Reading w/ Mesh Devices

A most basic problem. I’m having difficulty using a 2-axis analog joystick to analogRead on A0-5 using Argon or Xenon. Just using a basic code. What is it I’m misunderstanding here?

const int X_pin = 4;
const int Y_pin = 5;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print("\n");
  
  Serial.print("X Axis: ");
  Serial.print(analogRead(X_pin));
  //Particle.publish("X Axis", X_pin);

  Serial.print("\n");

  Serial.print("Y Axis: ");
  Serial.print(analogRead(Y_pin));
//  Particle.publish("Y Axis", Y_pin);
  delay(500);


}

@architek1, how is your joystick connected to power and analog pins on the mesh devices?

Sorry…A4 and A5 pins. Then I have a NCD breakout board with 5v and ground. It’s getting power fine as I measure the current. Works fine on Arduino Uno. Tested on both Argon and Xenon and 2 different breakout boards.

@architek1, the voltage going to any mesh analog or GPIO pin cannot exceed 3.3v. You may or may not have blown your analog input pins. You can test by connecting them to 3V3 and looking at the output then connect to GND and again look at the output. As for your pins, you need to use the correct Particle device pin definitions and not Arduino values. So instead of const int X_pin = 4; use const int X_pin = A4;.

1 Like

That seems to be the case. Those pins are no longer working on the Argon :frowning: Lesson learned. Running 3.3 from the xenon and changed pin definition A4 and A5. Thanks @peekay123!

1 Like