# Would the frequency of LED be equal to that of microcontroller

Suppose I have a simple LED driving circuit i.e. an LED and a resistor in series which is driven by a pin of a microcontroller. Now I set the frequency of this pin to say 1Khz, will the LED flash with the same frequency?

There might be capacitances in LED but I assume them to be small to have any affect or I may even be wrong(Oh and yes the capacitance would just vary the rise and fall times but it is good to be sure ). What are the possible parameters which vary the frequency of LED?

• What do you mean frequency? A red LED flashing at 1000 times per second will still be red if it is the question. It will only affect its intensity. Apr 25, 2016 at 14:46
• I mean if I set say 500hz continuously from the pin of microcontroller then will the LED be flashing with same frequency or would it vary @lucas92 Apr 25, 2016 at 14:49
• I think everyone's assuming there's more to the question because it's simple and the answer is "yes". Apr 25, 2016 at 14:56
• You should probe it at the oscilloscope, I checked many LEDs datasheets and there is no mention of their speed. At very high frequencies, the LED won't react fast enough and will output a DC signal due to internal capacitance. But I doubt you should use a LED for this type of application. Apr 25, 2016 at 14:57
• Practically, the only factors that will change the behavior of the circuit is your code - if you're using fancy macros to set the frequency to "1 kHz" but your clock frequency defines are wrong... or your math is wrong... or you are doing something weird with your timing....
– W5VO
Apr 25, 2016 at 15:02

That's correct. The LED will flash at the same speed as you toggle the pin, which in turn will be related to the frequency of the microcontroller.

Everyone's confused because they know something that you don't - you can't change frequency just like that! No passive or active device can do it. You mention capacitance (doesn't really exist in a LED but let's go with it) and you're correct. They will only change the rise/fall times. If the capacitance gets too high, you will see an effect where the LED will not have time to rise up to the high level until the microcontroller tries to make it low again, causing all the "toggling" to disappear and you will eventually end up with a voltage in between low and high, with some ripple.

The device that affects the frequency is just the microcontroller and its oscillator.

• RE: "No passive or active device can do it."... You can essentially make a frequency doubler with just a diode (whether you consider a diode to be a passive or an active device is a matter of semantics). For that matter, any nonlinear device, whether passive or active, is going to generate harmonics. Apr 25, 2016 at 16:11

At 1kHz 50% duty cycle (500usec on/500usec off) the light emitted will follow the port pin output very closely.

Once you get into the sub-microsecond region you may start to see differences based on capacitance and effects due to the LED itself not responding instantly (something like scores or tens of nanoseconds if the LED is driven hard). The junction capacitance will vary with forward voltage, like any other diode, and it's typically in the tens of pF for a small LED.