So I have a need to average out some AtoD samples & a bit of googling found this (DT's averaging routine)...

http://74.125.77.132/search?q=cache:...&ct=clnk&gl=uk

(Btw, yes I did use the search bt I've just climbed down off the chair having tried to catch all the info going over my head!)

Now that looks link above looks like it might be ideal (perhaps a hammer to crack a nut in my situation), except I don't have a clue how to integrate it into my code! (I'm still massively wet behind the ears & really don't know how I've managed to kludge what I've already got together!)

In a pretty crude manner, up until now I've been averaging by storing the AtoD values in a few variables - then adding them together & then dividing by the number of variables I've used. I removed it from my code because it wasn't very elegant, my (simple) code was getting bloated etc.

Could someone be so kind as to outline how I can elegantly/simply average say 16 samples on a rolling basis?

For any responses, can we sssume my A to D sample is stored in a variable called signal_in