Society of Robots - Robot Forum
Software => Software => Topic started by: bakil on July 21, 2007, 05:10:10 AM
-
can just somebody explain how i can calculate the period that a led needs to be off and on at lets say 3.69mhz (or use something else but mention it :D)
my goal is to build a function that you give a % and then the led is burning at that %
//------------ old topic -------------\\
does anyone of you people at societyofrobots know how to make an software PWM for fading a LED
my microcontroller runs at 4khz (i think this is the most easy frequency)
-> i know its something like 1micro seconde on and 3 microseconds off etc
-
If you tell us what microcontroller you are using and what language you are programming it in, I am sure we can help you.
-
ow woops im srry
i use C
atmega16L programmed with the stk500 board
-
This was designed for PICs, but it may work for Atmegas as well... http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calculator.html
-
If you have your LED off for 3us and on for 1us, that means your LED will only be 1us/(1us+3us) = 25% bright.