I connected a accelerometer to the analog input and PWM was successfully generated. The servo
You fed a servo PWM?
Sorry, that is not the right way to drive a servo - have a look at the Servo libraries.
A very simple filter:
int filtered = 0;
const int FILTER_CONST = 4;
...
...
int newVal = analogRead (potPin);
filtered = (filtered - (filtered / FILTER_CONST)) + (newVal / FILTER_CONST);