Are you digitizing a variable voltage produced by an analog potentiometer?
I have used gear like that and seen the jitter and flakiness in the values being read from the pots. In my experience it could be improved substantially by cleaning the potentiometers with compressed air and alcohol.
I suspect what the problem is that DC is naively being sent across the potentiometer, and then the divided voltage is sampled.
Audio designers know that significant DC currents flowing across potentiometers (which also carry audio) will add lots of scratchy, crackling noises when those potentiometers are moved (and maybe even when they aren't).
If I were designing a circuit which digitizes the position of an analog potentiometer (rather than the obvious approach of using a rotary or linear encoder), I would drop strictly an AC signal (from an oscillator) across the pot, with no DC component. This would then be rectified, peak-detected and digitized.
Another consideration is that cheap carbon pots are more noisy than ceramic, conductive plastic or wire wound units.
A very simple software technique to smooth values is exponentially-weighted smoothing. This is a beautiful trick which allows the smoothed value to depend on all prior values, without retaining a history of prior samples. (Familiar analogy: the charging of a capacitor is similarly exponential, and the current value depends on all the past currents. However, the capacitor has no memory, per se.) Looks like there is a Wikipedia page about it.
To implement exponential smoothing, simply keep track of the estimated value \$s\$ of the potentiometer (or whatever parameter \$x\$ you're sampling).
The estimator is initialized with the first sample:
$$s_0 = x_0$$
Therafter, when a new sample is obtained, we replace the estimator with a linear blend of the existing and new value, where \$\alpha\$ is the blending factor (called "smoothing factor" in this situation).
$$s_t = \alpha x_{t-1} + (1 - \alpha) s_{t-1}$$
This can be conveniently rewritten like this:
$$s_t = (s_{t-1} - s_{t-1})^{\rightarrow 0} + \alpha x_{t-1} + (1 - \alpha) s_{t-1}$$
$$s_t = s_{t-1} - s_{t-1} + s_{t-1} + \alpha x_{t-1} - \alpha s_{t-1}$$
$$s_t = s_{t-1} + \alpha x_{t-1} - \alpha s_{t-1}$$
$$s_t = s_{t-1} + \alpha (x_{t-1} - s_{t-1})$$
In other words, the new estimate is the old estimate, plus a fraction of the difference between the new sample value and the old estimate.
If all the quantities are integers and \$\alpha\$ is some power of two constant, this is very easy to implement in code. For instance, suppose we take \$\alpha\$ to be \$1/4\$, so that we blend 25% new value, 75% estimator:
/* C pseudo-code */
s += (sample - s)/4; /* optimizes to s += (sample - s) >> 2; */
/* s returned to caller as the value */
Exponentially-weighted smoothing implemented as one line: subtract, shift right, accumulate.
n
values. Would you want me to formulate this into an answer? \$\endgroup\$