DUE ADC Read Value Stability

The filter code is basically just a moving average of "n" readings where n = 32 in the example. It attenuates noise similar to a capacitor, except the response is more of a linear response than exponential. For quicker response (and less filtering), just use a value less than 32, i.e. try 8. The range is any divisor value from 2 to "unsigned long", however a practical range would be 2-32.

The reading is essentially stable in "n" (divisor) readings.

The signal can change fast, i.e. using analogRead() at 8,000 reads per second, and averaging 8 reads, "val" would have a response of 1 kHz.