Clean and energy efficient LED dimming

I think it is nuts for people to go into so much details just to control leds.

Having said that, one of the responders to the first link correctly identified the reason for ringing when switching a mosfet. That becomes a bigger issue when an inductive load (a motor for example) is being switched. I discussed that in one of my posts a couple days ago.

The last post's approach is excessively complicated. You can have a dedicated pwm controller to switch leds - those dc/dc converters with on/off pins are great for this.

Alternatively, you can use your arduino to perform conversion: you can use a sampling resistor + the analog comparator for cycle-by-cycle control; or you can use the sampling resistor + adc for averaging. The 2nd approach is very computationally intensive.