Noise reduction through deletion, not averaging.

I'm trying to get a sound sensor to control a servo or motor they way a potentiometer would. The problem is that the sound sensor hiccups a value to zero about every third millisecond or so, no matter the input. This sends the servo wiggy. I used a modified version of the smoothing example, but that cuts my highest results in half, and the thing is still kinda jittery. All I want to do is to have the Arduino ignore a reading of 0. I'm just not sure how to do that. Please help.

Well presumably at present you do something with the readings. So just don't do that something with a 0 reading.

if (getReading() != 0) {
doSomething();
}


Rob

Perfect! Thanks for the help.

to generalize AWOL's solution :

#define MINIMUMSIGNAL 3

if (getReading() >= MINIMUMSIGNAL)
{
doSomething();
}

furthermore instead of averaging you could use the median - Arduino Playground - RunningMedian - to prevent spikes