AnalogRead always returning the max value

Hello!
So, I'm doing an project on an arduino nano with two potentiometers, one of them is working perfectly, but the other one is always returning it's max value, but, when I was measuring the resistence of the potentiometer with a multimeter, strangely, it started behaving correctly.
This is the wiring diagram:


The potentiometer on A4 isn't working unless I measure the resistence between the ground pin and the A4 pin
This means I should do a pull down resistor ?
Thanks in advance btw

What happens if you swap the connections to A4 and A5 ?

It's the same, I tried it on the a0 pin too

Using a good DMM measure the voltage applied to the analog input channels. Next make sure your connections are tight. No, you do not need a pull down resistor. You can swap pots and see if the problem moves. Those are starters.

Ron

1 Like

Thanks for the answer
The voltage to the A4 pin is almost 4.95 volts constantly and on the other one, it changes when I turn the potentiometer
The connections seem ok, I tested the continuity on them
Also swapped pots, same result

Does your unseen sketch use I2C for anything by any chance?

And you are measuring resistance on a powered up circuit? This is a big No No and the results will be meaningless.

Plus what @van_der_decken said above.

This is my sketch

const int X_pin = A2, Y_pin = A4;

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

void loop() {
  int x = analogRead(X_pin);
  int y = analogRead(Y_pin);
  
  int buttonStates = 0;

  Serial.println(String(x) + "," + String(y) + "," + String(buttonStates));

  delay(40);
}

yea, I did it by accident first, I was going to measure the voltage and forgot to change it on the multimeter, that's how I discovered it fixed my problem temporarily

btw, measuring the resistance of the potentiometer on the A4 with the circuit powered off, the resistance is variable, I have no clue of what is happening

This makes me suspect that the wiring between ground and the potentiometer is broken. Another possibility is that the potentiometer itself is broken. Check the wiring and measure the resistance of the potentiometer between the end terminals.

1 Like

Does it make any difference if you put the delay between the 2 analogReads ?

Remove the pot wires from the analog input pins. Attach your BLACK meter probe to Arduino GND, attach your RED probe to the wire removed from A4, put your meter on "DC volts", turn the pot from end to end while reading voltage. What do you read?

man, thanks for the answer
it was both actually, the wiring between the ground AND the potentiometer ground pin
i think the wiring broke while I was testing the potentiometer, which seemed fine but I probably made a mistake on that

Good to hear. Without a good ground connection all the analog input was sensing was the 5 volt supply.

Thanks for the solution flag too.