> Anybody got a good averaging algorithm? > > NEWAVG = {(AVG*255)+DATA}/256 > A better way is to actually keep that sum of the last 256 reading rather that multiplying the average by 255. Thus you have NEWACCUM = (ACCUM - ACCUM/256) + DATA; AVG = NEWACCUM/256; Keeping those extra 8 bits around all the time reduces that error you noticed by your effect truncation of these least significant 8 bits. Dave Reinagel