Driving LEDs directly from MCU Pin

This is a "Please double check my work" post. Despite all the drivers and mods I've done, I've never actually worked with an 'indicator' LED before. In this instance it'll be a red and a green LED driven directly from an MCU pin.

Now to avoid blowing up the MCU (by pulling far too much current from it), we need to add a current limiting resistor. The MCU in question will be an ATTINY13A.

The first of the LEDs is this green one.

At a drive current of 30mA, the LED has a Vf of 3.2V. In order to limit the current to 30mA from a fresh 4.2V battery source (this is the voltage the ATTINY will supply), the current limiting resistor needs to be (4.2-3.2)/0.03 = 33.33'ohm or just 33ohm. The power rating of this resistor must be P = Vdrop*I = 1*0.03 = 0.03W

The second LED is this red one.

At a drive current of 30mA, the LED has a Vf of 2V. In order to limit the current to 30mA from a fresh 4.2V battery source, the current limiting resistor needs to be (4.2-2)/0.03 = 73.33' or just 74ohm. 75ohm is the most appropriate off the shelf resistor I can find. The power rating of this resistor must be 2.2*0.03 = 0.066W

Yay or nay?

Obviously if I parallel 2 or more LEDs (of the same color of course) my resistance will change as I want the drive current to be 60mA/90mA etc. For a pair of green LEDs from a single pin this would mean a single resistor of about 17ohm. Or just pair each LED with its own 33ohm resistor.

Obviously the sink current rating of the MCU is important here so I have to figure out what my maximum drive currents can be. I just used 30mA in the examples above as they are the standard operating ratings. If the drive currents need to be lower then I'll go datasheet diving :)

- Matt

You probably don’t want to be driving an indicator LED at 30 mA… it will be too bright. Try starting at around 5mA. I usually use around 220 ohm resistors… sometimes 1k.

This thought crossed my mind so thanks for confirming it. The LED has to shine through a fairly thick opaque rubber button. I might work off 5mA and buy resistors to cover 1mA up to 10mA.

My calculations are correct I'm assuming?

- Matt

They look OK… best to limit current to around 20mA per pin.

OK, sweet. Thanks!

Thanks for this post, I’m doing the same thing right now (driving the LED under the boot of my T4_MELD) so good info

http://www.digikey.com/product-detail/en/150080GS75000/732-4983-1-ND/4489913

Driven by attiny pin #5, through 1000 ohm resistor

http://www.digikey.com/product-detail/en/150080RS75000/732-4984-1-ND/4489916

Driven by pin #3, through 470 ohm resistor

I messed around with trying to pick resistors beforehand too, the calcs were way way too low (LEDs way too bright) for what works in reality.

Screw it, Comfy wins. I'll use the same resistor values you have picked. You've done the leg work for me! And yes, this is for the S1100 ;)

Matt, I have been patiently waiting for the big reveal. ETA?

No sweat Matt. Take your time and hurry up.

No idea! I've decided to build an entirely new driver so I'm waiting for the PCBs to arrive. Good news is the led is perfectly centered and focused with zero adjustment needed. Throws well at 3A so we'll see what it can do direct driven :) I should actually do some measurements!!

Awesome!

I should also mention that I've been inspired by your build, though won't be going crazy with it. I'm using a 50mm aspheric to do a Mag mod with an MT-G2 that should be pretty cool. The back focus length of the 50mm lens is only 26.2mm which is fairly close to the top of the mag body when the head is screwed just past the o-ring groove. That makes the build pretty straight forward. l like that I will be able to focus the beam to be more or less "spot" as needed.

Converting to parallel (:() or did you reverse engineer the stock buck driver?

Sort of like the ultimate zoomy lol. Could be a very useful light!

I removed the stock driver completely. It's completely intact although I am pinching the switch to ensure a stock switching action. In theory I could go back to the stock setup anytime I want.

Good info. I was considering doing the same thing with my SRK that I haven't touched in over a year that I installed an illuminated switch in - https://budgetlightforum.com/t/-/15114

I only have one light with an indicator (BST), but this seems like a fun thing to try… especially after I spent part of today writing a battery check mode. :slight_smile: