ATMEGA 2560 Pots Hooked Up to the Analog Pins not reading

Hello All,

I have two 10K pots hooked up to pins A0 and A1. They used to read nicely and smoothly. They gave me a brightness level for some LEDs I am driving. The LEDs are being driven just fine. The issue is that I am only getting a value of 255 out of my analog pins. I have changed the pins that I am using, and even changing the ATMEGA 2560. Does anybody know what is causing this? My code is simply an analogRead line.

TIA,

Zack

Check all your connections.

Please provide a wiring diagram (photo of hand drawn is fine).
Please provide your code.

How exactly are the pots wired to the board ?
Please post your sketch

The pots are wired such that the left pin when looking at it top down, is connected to GND, the middle pin is connected to the Analog pin on the Arduino, and the Right pin is connected to VCC. I would show my sketch but given the shear size of it is not necessarily practical to share it.

So there is more to it than just a simple analogRead(). Try to make a simple example that demonstrates the issue.

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

void loop()
{
  Serial.println(analogRead(A0));
  delay(1000);
}

What are the results?
If not as expected, disconnect everything else from the board and try again.

You said that it worked in the past; so what did you change? Code? Additional wiring?

I have added additional code and wiring. This system I am building is going to be massive. Roughly 50 digital inputs, about 10 pots, a few serial outputs to WS2812 strips, a few strips of 5050 LEDs etc. So I am not just building all my wiring and code from the getgo. I am building it out in stages. Once I have the functionality of these pots working reliably I will build out the next stage. Both the code and hardware.

I will build this sample sketch. It seems like a good troubleshooting step.

You're probably reading the value to a byte variable, instead of an int. E.g.

byte var1;
var1 = analogRead(A0);

will only give you 255 maximum.

We'd see that immediately, if you posted your complete code, in code tags. If it's more subtle, then seeing your code is imperative.

I seem to have found the issue. Apparently I accidentally connected the ARef pin to ground by accident. Now they are working fine.

Well, so much for my theory. If things are still working, count your lucky stars. Aref isn't usually that tolerant of abuse.

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