"Controlling the Brightness of an LED" ..
This example should give you basic idea on P(ulse)W(idth)M(odulation) generated by a microcontroller .. https://www.iguanalabs.com/pwm.htm
which microcontroller u r using??in 8051 u can use any timer with auto reload mode and enable the interrupt for this timer.then simply write the interrupt routine as u want.
if i using PIC12c508 & 12f508a? is it very easy too?
but i can't understand ,how to adjust cycle.because,
it had one timer and no interrupt . is it right?