New to Arduino Need help driving lots of LEDs

Bottom line up front: Need some help figuring out how to proceed with my project, and how to size a base resistor for a 2N3904 to drive multiple LEDs off one arduino pin. Or possibly ideas I might not have thought of.

Verbose issue: I have a costume project I'm working on, basically it is a glove with lilypad LEDs running along the front of my fingers, hopefully in red, yellow, and purple. I'm kind of at am impasse, I've made some purchases already, but unfortunately I didn't notice the 40mA/3.3V limit on output PWM pins before purchasing the Lilypad Arduino USB.

I got the Lilypad Arduino USB to keep components down since all the hardware needs to fit on the back of the hand and it connects directly to the 1000mAh 3.7V lipo battery I bought. I also purchased 20 of the leds (10 red/5 yellow/5 purple), and I intended to either drive 5 leds on 4 pins (4 fingers) or 4 on 5. Either way there is going to be too much current draw for them to be very bright. I plan to just have the 4/5 LEDs on each finger pulse/fade/flash etc out of sync with the other fingers, I don't need individual control, but I do want each finger to have at least one of each color LED.

I saw some suggestions online about using some 2N3904 transistors to get the required current, but I am unsure as to how to size the base resistor. The lilypad LEDs all have 100ohm resistors already attached (too big IMO), so that variable is fixed. With 3.3v that gives me a pretty lame 13mA on the reds/yellows, and <6 mA on the purples giving me about 45mA draw for the 4 on 5pins configuration.

I've tried this calculator, specifically the calculation at the bottom (vbe=0.95, hFE = 50, Ic = .045, Vi = 3.3, Rb result 870ohms) but I'm not sure if I trust the calculation. How accurate do I have to be with the ohms? Should I go under or over? Also, can I just run the Vcc off the 3.3V pins from the Arduino?

Since with 3.3V the purples will barely show up (might even remove them) another possibly I was mulling over was purchasing the full Lilypad arduino with the 3.7 to 5V step up secondary circuit so I can do 5V instead of 3.3V, I'd still need to do a transistor circuit, but the issue with this is I am worried about blowing out the red and yellow LEDs since with 100ohm resistors, they would see the datasheet-stated maximum 30mA current.

I've already spent quite a bit on this, but I want to do it right, but on the gloves there is not a lot of real estate, between the battery, the arduino, and the 5 transistor circuits (I'll be making them on 1" proto boards 2-3 per board). Brightness is key as they have to illuminate semi-transparent objects I will be holding in my hand. My fallback is to drop the arduino, and just hook the lipo through a switch directly up to all the leds, forgoing the "sfx."

Sorry for the novel, I just wanted to make sure I touched on all points. Thank you for any help you can provide.

With only 3.7v supply, you will not be able to connect any in series so you need a driver for each LED string of all wired in parallel with a small current balancing R in series with each LED.

If you are using common basic LEDS, they will need about 20mA. Work out your dropping R using Ohms law to drop the difference in LED voltage and supply voltage.

The switching transistor will drop some voltage as well, could be up to 1v so you may not need much R.

The Tr base R only needs to turn it on fully. At your supply voltage 2.7k to 3.3k should do the job.

Weedpharma

Thank you for the reply, I do know I need to connect in parallel, unfortunately, due to the space constraints (and need of flatness) of my design I needed to use pre-made surface mount LEDs, here is a link to what I bought: LilyPad LED Red (5pcs) - DEV-14013 - SparkFun Electronics. They already have 100ohm resistors on the micro-board, so I have to deal with the 13mA (3.3Vs, Vfwd=2v, 100ohm) for the red/yellow and a horrible sub <6mA for the purple (3.3Vs,Vfwd~3.2v, 100ohm). I'm stuck with what is available on the net. The only other ones I've found have 220ohm R's built in which is much worse.

That was why I was thinking of using the standard Lilypad Arduino, which if I am reading correctly can output up to 5v (after boosting the power on the front end) on each pin rather than 3.3v. That would give me enough to drive the purples pretty brightly, but might blow out the reds/yellows (5Vs, Vfwd=2v, 100ohn gives 30mA, right at the maximum given on the datasheet).

So, if I am reading your last sentence correctly, the base R can be fairly large as long as it hits some threshold to turn it on? I just want to make sure I'm getting the maximum brightness I can get, but these LEDs are so expensive ($4+shipping for 5) that I don't want to blow any out.

That is very expensive for LEDs you should be paying about $0.20 each at the most.

Why not use the neopixels from Adaafruit? These are very versatile for what they do.

"So, if I am reading your last sentence correctly, the base R can be fairly large as long as it hits some threshold to turn it on? I just want to make sure I'm getting the maximum brightness I can get, but these LEDs are so expensive ($4+shipping for 5) that I don't want to blow any out. "

The Tr is being used as a switch so you need simply enough base current to turn it on fully. The Tr will not cause the diodes to fail, it is the current through the diode that is the important thing. I was unable to read the data but would think that up to 20mA should be ok.

Weedpharma

Flora neopixels are even more expensive at $1.75ish a piece(granted they are more versatile as you say, but that isnt necessary for my application), plus either they or the flora controller (probably not necessary) are always out of stock.

You limit yourself in having to buy ready made boards. You can solder a suface mount LED between the copper tracks on strip board and use surface mount resistors as well. Use of a scalpel on the strips allows even finer work to be done.

That sounds like a good idea, but I would have no idea where to begin or how to solder those (and my soldering skills are really bad).

Just looking online shows multiple different sizes of surface mount LEDs (603, 1206, etc). Navigating mouser or digikey requires a degree in data management, a map, and some level of Aspberger's. But I did manage to find some prices. ~0.08 for 68ohm resistors, ~0.35 for smd leds, and ?? for strip board. With shipping I'm still more expensive than the premade ones, and the premade ones are tinned better for use with the conductive thread. Though in this case I could buy more to offset shipping costs I guess.

All of this is 20/20 hindsight anyways. I've spent the money on what I have and need to figure out a way to make it work as efficiently as possible, another arduino I can find a use for, binning all these LEDs I cannot.

No offense, and I really do appreciate the help, but changing the LEDs (due to price) was not part of my issue. I am probably going to go the 5v route and just attach some 68ohm resitors in serial to the reds and yellows, that will get me down from 30mA and just shy of 20mA, while still allowing the purples to get their 20mA. I was just hoping for a more elegant solution.

For even brightness over battery life time, I would convert to 5volt with with this very small boost converter.
Monitor battery voltage with the lilypad, so you don't drain it below 3volts.
If you use the 2N3904, use 1k base resistors, so saturation voltage is low (0.2v).
Use the LEDs as intended. For a 5volt supply.
With this, and 15 flashing LEDs, you might get 4-8 hours of action from a good 3.7v/1Ah battery.
Leo..

I was able to purchase a lilypad version of that boost converter on ebay this afternoon. I also have a few voltage displays that I may have space to work into the build, though the battery I bought does have a protection circuit. I ran a single finger test circuit (including the series resistors on Red/Yellow making those 168ohms total) through docircuits.com earlier:

And then did a DC sweep of the base resistor, and got these values. Looks like 1k is a safe bet (right click, view image, to make it bigger):

The LEDs in the program are probably not super accurate to the SMD ones I have I'm sure so the numbers probably aren't perfect, but I am in the ballpark.

Now to figure out how to fit it all on the glove. If anybody is interested, my end goal is to have a glowing/flickering plasma like visual output, which will be translated through some semi-translucent objects (including the ubiquitous playing cards) for a Death Horseman Gambit (X-men) costume I'm making. Thanks for all your help.

You should be able to get more brightness using a MOSFET.

You can get more brightness by using a MOSFET to do the switching. They do not suffer the voltage drop as in normal Trs.

What you need is a logic level gate mosfet. The gate needs to be fully on or the resistance of the drain/source is not at its least so causes heat.
My favourite small mosfet is NTD5867NL. It works with 5v on the gate and handles a few amps with ease. They are cheap. I bought mine from RS Components.
There are others but make sure they are fully on at 5v on the gate.

Weedpharma

Would this suffice? http://www.digikey.com/product-detail/en/NTD5867NL-1G/NTD5867NL-1GOS-ND/2401422

Its been a long time since I've done anything with MOSFETs, do I need a resistor between the pin and the gate, even a small one?

Looks like the same part number.

To use it, put a R (470 ohm or so) between the output pin and gate, and a 10k or more from output pin to Gnd.

Weedpharma

So like this:

Unfortunately docircuits doesn't have a model for this mosfet, but I tried a couple they did have models for, and the amps were much closer to the 20mA I hoped for.

edit: updated image

Looks good.

Weedpharma

Awesome. Thanks!

I would make R4 lower so the FET turns on faster and so does not get as hot. It is needed for protection of the Arduino output pin from surge currents when switching but only needs to be 130R