Potentiometer showing different values for the same position

I'm trying to read analog value controlled by potentiometer. I receive different values for the same potentiometer position. For example, when I expect to receive 0, times to times I receive 1 and 2.

Code:

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

void loop() {
  int value = analogRead(A0);
  Serial.println(value);
}

Scheme:

Serial console with values:

image

That is what they do. Good quality potentiometers are better, but they still have that.
Only in a simulation (such as in Wokwi simulation where you made that picture :wink: ) it is perfect zero, but not in real life.
In software, you can add a filter or hysteresis.

1 Like

Did you consider that there are only 1024 possible results of reading the A/D converter, while a 10k potentiometer has 10,000 possible positions?

1 Like

Hi, @pavlo_makk_old
What is your application?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hi, @TomGeorge
I just want to test my BLDC motor. Use potentiometer as input for speed value of the motor

A capacitor from the wiper to groud will hep to bypasss noise. A starting point is the 0.1uF ceramic cap. It will not eliminate noise, but shoud reduce it.

Connect a 0.47uF capacitor from A0 to GND, if it's an electrolytic capacitor connect the + side to A0, see if that helps with "jitter".

As you can see, a wide range of values can be used. Many times one will see 2 or more caps connected in parallel. Each cap's value will allow it to bypass different frequencies. A 0.1uF ceramic cap will help to bypass higher frequencies. The 4.7uF is more effective at lower frequency.

Analysis and/or observation will indicate which to use in this case.

Hi, @pavlo_makk_old

So you want to calibrate the pot position for a given motor speed?

Have you built your project to see what the response is?

If not then do so, you may be OVER THINKING the system.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

In fact, unless it's a wire-wound potentiometer, it has a virtually infinite number of positions!

1 Like

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