This is nice article but every engineer would say this is oversimplification for simple usecases like status LEDs on router. LEDs are tricky to make behave predictably as they are non-linear components, sensitive to temperature and no two LEDs are made the same. This really shows when connected in parallel.
Also different colors of LED have different efficiency.<p>These issues are more prevalent if you're trying to make high-power LED circuits or some RGB circuit with accurate representation of colors.<p>Always thought LEDs are my friend but they made me lose some hair in last years.
It's worth noting that while it isn't within spec, and certainly isn't good engineering practice, in most cases connecting an LED directly to a microcontroller output pin with no resistor works just fine.<p>Most microcontrollers have effectively a fixed output drive current of something between 10 milliamps and 50 milliamps (which depends on the size of the drive mosfet on the output pin, and might be different for pull-high vs pull-low mosfets). Most LED's can handle that just fine.<p>The energy that would have been dissipated in the resistor ends up dissipated in the microcontroller instead, but that normally doesn't lead to issues.
It seems to be an article-length piece, leading up to a downloadable spreadsheet. That's ... not so accessible. I quickly found [1] at Digi-Key which is a simple online calculator. It also features a handy table of reference voltages for various colors of LED, which I appreciated.<p>Ideally I guess the color should be choosable and used to populate the voltage, but that seems to be Super-Advanced Thinking in this area.<p>The full set of calculators [2] seems quite impressive and useful, too.<p>[1]: <a href="https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-led-series-resistor" rel="nofollow">https://www.digikey.com/en/resources/conversion-calculators/...</a><p>[2]: <a href="https://www.digikey.com/en/resources/online-conversion-calculators" rel="nofollow">https://www.digikey.com/en/resources/online-conversion-calcu...</a>
Even when you apply the formulas in the linked spreadsheet, you can get into trouble because it seems to assume V_led is fixed.<p>For an example of how quickly this can go wrong, see my accepted answer to “Why is my LED circuit drawing 50% more mA than I calculated?” <a href="https://electronics.stackexchange.com/questions/572739/why-is-my-led-circuit-drawing-50-more-ma-than-i-calculated" rel="nofollow">https://electronics.stackexchange.com/questions/572739/why-i...</a>
While we're talking LEDs:<p><a href="https://gist.github.com/phkahler/1ddddb79fc57072c4269fdd6716bfb72" rel="nofollow">https://gist.github.com/phkahler/1ddddb79fc57072c4269fdd6716...</a><p>In 6 lines we smoothly blink (fade on and off) an LED on a regular GPIO pin. Uses some fixed-point math and pulse-density modulation.