Imagine a "long" variable "x" as an array of four "byte"s "xb[4]" (define a union).

Because the Arduino is little-endian, the most significant eight bits of "x" are held in xb[3].

xb[3] will the value written to our PWM device.

Now, if we set "x" to 0x01000000, xb[3] will contain 0x01.

Assume we want to fade x from 1 to 5 in 300 steps, so we take the difference of 5 and 1 (4) and divide by 300, yielding 0.0133.

Now, multiply 0.013333 by 2^{24} (= 16 777 216) to give 223 696 (0x000369D0)

Store this value in a "long" called "inc".

Now, repeatedly add "inc" to "x", but only write xb [3] to your PWM device each time through the loop.

This technique is most useful when you've got a number of LEDs to fade to and from different values, but in a fixed number of steps.

(it comes out a lot easier than I described it!)