analog input readings help

I'm using a 10k pot's middle pin to go directly in to analog A0.
The line of code I use is

incomingsignal = analogRead(analogPin);
  waterpressure = map(incomingsignal, 0, 1024, 0, 100);

I then send the result to a couple 7 segement leds.

I get a lot of bouncing around, like noise on the input pin. Am I able to use a resistor or anything to clear it up. I have read many other posts about Analog input noise but can't seem to find the best solution.
Even if I unplug the wire from the analog input it still shows a small value bouncing around.

The Pot is there just temporarily to simulate a water pressure sensor that I'm waiting for in the mail.

You can add a capacitor between Analog-in and ground (maybe 0.1 to 1.0uF). You can also use software [u]smoothing[/u]. or, you can use some hysteresis or other logic to ignore small changes.

...With analog-to-digital conversion, you can always be "on the edge" between two numbers so it's not unusual to jump-around by 1 digit, even with a "perfect" setup.

Great thank you. If I use a capacitor, between analog in and ground how woukd I wire that?
Just put my signal line from the pot to one row on the bread board and from same row run a wire to input and also same row a capacitor lead and other lead to ground? Thank you


Are your variables set up like this?

word incomingsignal = analogRead(analogPin);
byte waterpressure = map(incomingsignal, 0, 1024, 0, 100);

No, actually both were set up as int but I changed it to your suggestion and it still "flutters" around and can't get the value to zero. I'm not super concerned with precision I don't mind if it bounces around by 1 or 2 because I only need within about 5 for this project, but I would like to allow it to go down as far as zero.. When the pot is turned right down, or when the signal wire is completely unplugged from the analog in, it flutters around 3, 4 , 5....

could someone kindly explain how the capacitor would help this? I know that a cap will hold current then discharge....

Thanks alot everyone..

When the signal wire is unplugged, the input is floating, so you could read anything from 0-1023.
Reading 3,4,5 seems normal for a basic pot ... at the wiper ends it may not make a perfect connection to GND or VCC. A capacitor will help keep the readings stable ... readings jumping from 3,4,5 would probably settle at 4 with a 0.1µF capacitor.

If it settles at 4, you could use:

waterpressure = map(incomingsignal, 4, 1023, 0, 100);


If the 3,4,5 readings is in waterpressure, then you could map a slightly limited range, say 4-96% of the pot reading becomes 0-100 in waterpressure:
waterpressure = map(incomingsignal, 40, 983, 0, 100);