Current monitor for fan running with PWM through FET

Btw, i still don't really understand, how to synchronize the analogRead with the PWM (to measure without low pass filter). Can you give me a code example? This is my part for measuring current:

I don't think such a method exists, In the external (to the AVR chip) electronics world the PWM lives in the digital domain and the analogReads lives in the pure analog world, they are only equally digital inside the code, So external low pass filtering to eliminate the PWM switching frequency will always be required, unless someone can prove differently?

On second thought, I guess it would be possible to implement a low pass filtering function in code to take many analogRead samples and effectively filter out the PWM switching frequency, might be an interesting project for someone better at software then me. :wink:

Lefty