First be aware that analogWrite() which I guess is what you're talking about, only goes as high as 255. There's not an infinite number of jumps available. At 5 per 1/2 cm, that's 51 jumps of 1/2 cm, giving you a working range of 25cm; is that what you have in mind?
So perhaps you envisage an item further away that 25cm, and the led is off. As it approaches 25 it stays off. Then at 25cm it comes on dim, and as the object gets ever closer the led gets brighter, until when it's up against the sensor (if the sensor reads that close, anyway) the led's full on?
Is that the idea?