When I open the serial monitor from the arduino is can see that the analogue output from the potentiometer randomly fluctuates say +/- 5 points over the 0-1023 range as the programme loops through.
I assumed that as this is sent to the processing sketch that this what is causing my problem.
I did link the power and grd with a capacitor to see if that would help but it didn't seem to make a difference. (I'm no electronics whizz, however)
do you have the ends of the slider connected to gnd and 5v respectively, and the wiper connected to the analog input? why not take a series of reading, and submit the average? Could be you have a defective wiper, or it sees a "floating input" ...
I have two wipers and both behave the same - they seem pretty solid - I don't think that they are defective.
I put a 100millisec delay into the arduino programme and this reduces the frequency of random fluctuations as taking an average would, I guess, but doesn't eliminate the problem.
The sliders are on the end of 30cm wires so maybe electrical noise looks like a good suspect.
I'll see what the internet says about reducing this...Do you guys have some tips?
That is not a huge variation on input counts and could be caused by several reasons. Noise, either in your voltage source, or too high a pot resistance value (you didn't state the value of the pots), 10k ohms or less is what the analogReady() command is optimized for. There are several things you can try both in hardware and software. A .1ufd cap from ground to the analog input pins being used for both pots can help solve the problem of too high a pot source resistance. And various software averaging functions (take many readings, sum their values and then divide by the number of readings used) can help calm down input variation.
The process of averaging seems to have resolved the majority of the problem. I'll play around with the variables of the averaging calc to make sure that the movement remains responsive.
huskerwr38:
Make sure that the input pin on the Arduino has the pull resistor enabled.
What? Why? How would that help?
Lefty
So that the input goes to a known state until it is changed by an outside influence and prevent the pin from floating and assuming undefined values. The OP said that the values change even if they do not touch it, which to me might mean that they do not have the pull up resistor enabled so that the input goes to a known state. He shouldn't have to average out the values to get it to stop fluctuating. I had this exact same problem with an LED once, when I had it turning on and off, with a button. The LED kept flickering when it was off because the input pin connected to the button was floating. As soon as I enabled the pull up resistor it stopped flickering. I'm just basing this off of what I experienced.
huskerwr38:
Yea, I suppose my advice doesn't really apply to analog inputs only digital inputs. Sorry about that.
No your advice doesn't apply to a pin that's already controlled by a 10k potentiometer - its not floating.
Both digital and analog inputs can float if left floating (so to speak).
If the cable between the pot and the Arduino isn't a screened cable then that would more or less guarantee some
noise-pickup. At the very least signals should be screened or twisted with a ground wire ("twisted pair") if going any
distance.