# Potentiometer Jitter

I have potentiometer hooked up to my Arduino Mega - 5V, GND, Analog Pin - the pin value seems to float or jitter even when the Pot armature isn't being moved - do I need a resistor to GND on this device to reduce this? regards Patrick

A capacitor between the analog input and ground may help to reduce noise pickup, especially if the pot is 10K or more and/or if the leads are long and unshielded (try 0.1uF or greater). You can also try software [u]smoothing[/u].

If it’s jumping up & down by 1 count, that can be normal if you are on the “hairy edge” between two numbers. That’s just the nature of analog-to-digital conversion. You can handle that by ignoring changes less than 1 or 2 counts, etc.

pnhealey: do I need a resistor to GND

One side of the pot is a resistor to ground; the other side's a pullup.

So if you put a separate resistor to ground, that will just upset your readings since it and the bottom of the pot will just be a parallel resistor pair and simply change the characteristics of the divider.

(Say your pot was 10k and you had the wiper in the middle, 5k either side. Let's further say you added a 10k pulldown. Then the bottom "half" becomes 1/ (1/5 + 1/10) = 3.3k not 5 and you now have an 8.3k pot not 10. And your "midway"reading instead of being 5/10 = 0.5 will be 3.3/8.3 = 0.4)

Hi, and welcome to the forum.
I assume you use a 10k lin pot (10kB or B10k), and that your supply is stable.
“Smart” code can eleminate the problem you have.
Look at this sketch that I wrote for some 0-100% project.
Leo…

``````// converts the position of a 10k lin(B) pot to 0-100%
// pot connected to A0, 5volt and ground

int rawValue;
int oldValue;
byte potPercentage;
byte oldPercentage;

void setup() {
Serial.begin(115200); // set serial monitor to this baud rate, or change the value
}

void loop() {
// ignore bad hop-on region of a pot by removing 8 values at both extremes
rawValue = constrain(rawValue, 8, 1015);
if (rawValue < (oldValue - 4) || rawValue > (oldValue + 4)) {
oldValue = rawValue;
// convert to percentage
potPercentage = map(oldValue, 8, 1008, 0, 100);
// Only print if %value changes
if (oldPercentage != potPercentage) {
Serial.print("Pot percentage is: ");
Serial.print(potPercentage);
Serial.println(" %");
oldPercentage = potPercentage;
}
}
}
``````

DVDdoug: If it's jumping up & down by 1 count, that can be normal if you are on the "hairy edge" between two numbers. That's just the nature of analog-to-digital conversion. You can handle that by ignoring changes less than 1 or 2 counts, etc.

This can actually be desirable if you're using oversampling and decimation to improve accuracy; Atmel has an app note on this.

This will help.

It is a low pass filter.

ScanPoti.pdf (80.9 KB)

Thanks every one!!