Problem with pot

So I'm reading a value from a pot and it returns a value between 0-1023, all well and good.

BUT when the pots value goes to zero it will only go back up to around 250 and then sticks there for the remainder of the turn.

I can go down as low as 2 and return to 1023, but as soon as I hit zero, it sticks.

Any ideas or solutions short of physically restricting the pot so it doesn't reach zero, which would be far from ideal?

Is this a linear pot or rotated pot? Have you tried replacing it with another? It may be the pot or it may be something else - difficult to tell from the given info.

Post your test code, please.

Read the forum guidelines to see how to properly post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Hello @pixip
To provide a helpful answer the very minimum we need is code and a schematic of how you wired it it up. Also helpful are links to the actual products you have and photos of of what you have made.

Thanks,

It's all pretty basic, can't see how it can be going wrong.

int pinIn = 3;
int potVal;

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

void loop() {
  potVal = analogRead(pinIn);
  Serial.println("potVal = " + String(potVal));
}

You are streaming data very fast and, perhaps, flooding the serial port. Try this code that slows it down to 10 samples per second. And gets rid of the use of the potentially problematic String class. Does this improve things?

const byte pinIn = A3;
int potVal;

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

void loop()
{
   static unsigned long timer = 0;
   unsigned long interval = 100;
   if (millis() - timer >= interval)
   {
      timer = millis();
      potVal = analogRead(pinIn);
      Serial.print("potVal = ");
      Serial.println(potVal);
   }
}
1 Like

Wow that works, thanks.

If you want to add some stability to the readings from the pot, put a 0.1uF cap from the wiper to ground. That will act as a low pass filter to bypass higher frequency noise to ground.

Thanks for the tip