Electronic – Arduino PWM controlling high-power LED

arduinocurrentled

I'm wanting to use one of the Arduino's PWM output to control a high-powered LED. I can't remember the exact specifications, but it was considerably more current than the ATMega328 can provide.

I realise that this would usually be achieved with the use of a transistor, and a resistor to current-control the LED. However, I'm not wanting the LED to become less bright as the battery voltage sags, and therefore I'm wanting to use a constant current source instead of the resistor.

My first thought was to use an LM317. What I'm wanting to know, though, is if it can respond at the 64KHz it would need to?

Alternatively, could I use a simple MOSFET to achieve the same thing cheaper and simpler? (Then I wouldn't need a transistor nor constant current source, as the MOSFET would do both of these)

Thanks,
Rob.

Best Answer

You don't need 64kHz for this application, 200Hz is enough.

I've used the following design, for about 200mA current:

+5V --- LED --- transistor -(1)- shunt (1 Ohm) --- GND

(1) goes to the negativ input of an LM358 OpAmp. It is important that the OpAmp works down to the lower rail (GND), because there is only a small voltage on the shunt.

The output of the OpAmp drives the transistor via some appropriate resistor.

The positive input is connected to a voltage divider which is fed from the port pin. The voltage divider and the shunt determine the current through the LED.