Fade PWM in (almost) realtime.

modemover:
I can use a For loop, but i run the danger of the loop taking longer to complete than the clock takes to cycle if i only increment by one. I could do larger increments but loose resolution.

Decide how many steps you want to have i.e. how smoothly you want the change to occur and then work out how long an interval you need between each step, and then alter the value by one step at that interval.