Current control of LED in real time

Hey guys,

I'm designing a system in which I have to control the current that goes through a micro LED. The current will be somewhere around 20mA. I want to be able change the control current trhough the Arduino Software, in real time. What do you suggest I should do?

Thanks in advance! :slight_smile:

Use a PWM pin and change the average current through an analogWrite call. You still need a resistor in series with the LED to limit the maximum peak current.