Using PWM to increase voltage through LEDs?

This is a good course…well written and presented. I wish it was around a couple of years ago when I first started with Arduino and electronic projects. There is one thing I’ve ‘discovered’ about LEDs that you do not cover. Arduino PWM can allow higher voltages (5V) to be used with most LEDs without using a resistor. That is, a blue LED with a forward voltage of 3.0v can be used on a 5V Arduino board *without a resistor* if analogWrite() values are kept below 128. How far the voltage can be pushed will depend on the specification of the LED and the frequency of the PWM, but I’ve have yet to find an LED that I could not drive directly from an Arduino as long as I keep the average current through the LED at 80% or below the rated current for that LED. It is my understanding that using PWM in this fashion simplifies the circuit, reduces the current draw of the project, and reduces the average current through the Arduino pin. Of course not every project has PWM pins to ‘waste’ in this fashion. Thoughts?

randofo22 days ago

When working with microcontrollers, it is still generally better practice to use a resistor. If the pin gets pulled high for some reason (such as during bootup or reprogramming), you can potentially fry the LED. Also, as you mentioned, it ties up a microcontroller pin to use it in this fashion.

In my opinion resistors are so cheap and small, it is better and safer to just use one. I'm of the opinion that a simple hardware solution is typically better than a software solution.