Wikipedia has a page on moving averages. en.wikipedia.org/wiki/Moving_average

I'd suggest at first try an exponential moving average: average= a*sample + (1-a)*average. Experiment with different values of a (with 0 < a <= 1).

The smaller a is, the smoother the curve, but also the longer (more iterations) it takes for an actual change in the input to be reflected in average.