counter set up and average result

I'm trying to set a sampling counter loop with an average result after 20 samples. I'm lost in the syntax and would like some gentle help, I'm a neophite at this. Below is how I think it could be:

{sample=1to20; samples=sample+analogPin; delay(250); next sample; temp=samples/20; Serial.println(temp); samples=0;}

Any suggestion? ...

You have the right kind of logic going on there, but the syntax is a bit off.

Try looking at the details here http://www.arduino.cc/en/Reference/For and see if that helps.

Oh and you would also want the line adding up the total to be of the nature, samples=samples+analogue pin, rather than sample+analogue pin (using sample and samples as names for different variables makes it easy to use one where you meant to use the other without meaning to - and can be difficult to spot when it comes to debugging)