Solutions to smoothing algorithms. Code below smooths out an analog signal, it needs 3 variables, data (sensor signal) smoothed var and the alpha variable which can be set to change the smoothness.
if (data > smoothed){
smoothed = smoothed + (data - smoothed)/alpha;
}else{
smoothed = smoothed - (smoothed - data)/alpha;
}
if (smoothed < alpha){
smoothed = smoothed - 1;
if (smoothed < 0){
smoothed = 0;
}
}
data = smoothed;