arduino programming looping

I am using a sensor which is connected to arduino and an LED connected to any of the analog pins, now i want to make a program in such a way that as the sensor gets high the LED should glow in a dimming way from 0 to 100 PWM fade in, and when the sensor gets low the led should again move from 100 to 0 PWM fade out, can anyone please help me in the same. If possible with a sample program.

Yayy, a fellow noob! I don't know anything, but I did find this thread: Dimming led with IR proximity sensor - Programming Questions - Arduino Forum

Looks like there is some joy at the end. What kind of sensor are you using?