To have a variation in the dim, you have to change the value of d0 after each VBL.

You start with D0 = 1
Then, the next time, d0 = 2
Then, the next time, d0 = 3
...
Then, a little before the full lignted led , d0 = 254
Then, a little before the full lignted led , d0 = 255
Then you let the led ON

(I don't remenber the time and values to use, you'll have to search them).

If yopu want to go from light to dark, it's just the opposite :

You start from a light led and stop it a little before light it again :

Light OFF
loop do
Light ON

You start with D0 = 1
Then, the next time, d0 = 2
Then, the next time, d0 = 3
...
Then, a little before the led is full off, d0 = 254
Then, a little before the led is full off, d0 = 255
Then you let the led OFF

The main idea is to increase or decrease the time when the led is on/off during the time to have it dim more / less.