0705290 has given an example of a
FIR Filter. Basically, the output is the weighted sum of past readings. With 07's code, you can make all sorts of filters by changing the weights.
I also like using
IIR filters. These hold state a little differently, and I find the simple low pass IIR the easiest to tune.
Code:
tau = .75; //This is the tuning variable
pwm_out = tau*sensor_in + (1-tau)*old_pwm_out;
old_pwm_out = pwm_out;
This does a passable job of modeling a resistor - capacitor filter - tau is the equivalent of the RC time constant, ish.
To tune the filter, you can link tau to a wheel input. Play with it until it feels right, and record it.
Also, I did this in floating point math, converting it to fixed shouldn't be too hard.
Have fun!