Hi, I am in the process prototypin an AE module based on an Arduino pro micro and I have connected the wiper pin of a potentiometer to an analog pin of the arduino, and one of the outer pins of the potentiometer to ground and the other to Vcc. When I check the read value of analogRead() I notice that the value fluctuates the whole time even if I don't twist the potmeter's shaft. Is this normal or did I build my circuit to simplistic or is this to be solved in software through some kind of EMA.
You can also just >> and << it and ditch the least significant bit. 8)
Yep, it's called hysteresis.
This might help a little bit, but is not a real hysteresis: Think the current lowest two bits are "1" and the new ADC value increases by 1, then the third bit jumps, and cutting the lowest two bits has no effect, except for getting a jump of +4 in the result - not really what we want ;-)
A real hysteresis works like this: - create a buffer variable - calculate the absolute difference of the stored value to the newly read ADC value - If the difference to the buffer variable is greater than x (the hysteresis) then update the buffer and use this value, otherwise discard the ADC value. Use signed ints for this.