Hi rags,
I can help you with that.
What target device are you using?
If I know that, then I can create a little demo program for you in AVR format.
But the general principle of controlling a brightness of an led is to keep the frequency the same (at lease 100Hz minimum) but vary the duty (on to off ratio).
E.g if duty is 10% ie on time is for 10% and off time is for 90% then the LED will be dim.
If duty is 85% ie on time is for 80% and off time is for 15% then the LED will be nearly, at maximum brightness.
There are two ways of producing a fixed frequency with a varying duty cycle.
1) By far the easiest is use the built-in PWM component assuming your target device supports it. You can find the component within the Mecatronics menu
Just select PWM, then drag a component icon and select PWM(0) and Enable. If only 1 PWM then nldx will be 1
(if two PWMs then ndlx=1 for pwm(0) and ndlx=2 for pwm(1). I wont go any further as I can produce a flowchat to help you with PWM components.
2)Using timer0 overflow. There is an interrupt tutorial here:
http://www.matrixmultimedia.com/article.php?a=55
But the basics of the timer interrupt (not my words)
A interrupt is a signal that stops the current program forcing it to execute another program immediately. The interrupt does this without waiting for the current program to finish. It is unconditional and immediate which is why it is called an interrupt.
So the interrupt could be used to generate the fixed frequency.
If your target has PWM component, would you like a demo program with PWM component or Bit bang timer interrupt method?