Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: dutchboy on Nov 18, 2011, 07:38 pm

Title: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 18, 2011, 07:38 pm
Hi all,

I've been googlin' like mad to try and work out a way of running a string of parallel leds off of one arduino pin.

After mucking about with transistors I think what I needed was a FET. I wanted to run 10 leds of the one pin and came up with the circuit attached (hopefully self explanatory) but to be honest I really just had a look at other similar circuits hence the 100R resistor and 10K to ground. I put these in as I have seen them on many other similar circuits but don't understand fully why (apart from limiting the output current of the arduino pin). I figured after a while (and some ebaying!!!) to hook this up and see if i got my desired result and it seems to work with the standard fade example, but was wondering if anyone had any reason why I shouldn't do this, i.e blowing up my arduino, damaging pin etc.

Circuit attached and data sheet for the FET used.

BS170 N Channel FET rated at 500ma - www.fairchildsemi.com/ds/BS/BS170.pdf (http://www.fairchildsemi.com/ds/BS/BS170.pdf)

Thanks for your time.

Title: Re: Multiple leds on one arduino pin?
Post by: CrossRoads on Nov 18, 2011, 08:47 pm
Looks great to me. Gonna be very bright - wear shades!

100R limits current out of arduino into the Gate capacitance of the MOSFET. (Uncharged cap looks like a short circuit.)
10K keeps the MOSFET off while the Arduino resets and all IO pins are inputs, prior to sketch taking over and turning them off or on.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 18, 2011, 08:57 pm
Hey there CrossRoads,

Looks like the research paid off lol. Thanks for your response. Bright is exactly what I was going for. Gonna transfer these to some RGB's and make up some bright strips!!

Thanks again.
Title: Re: Multiple leds on one arduino pin?
Post by: CrossRoads on Nov 18, 2011, 10:28 pm
Ok, the Resistors may have to change then. Vf of LEDs varies a lot by color.

I thought I was looking at one of my old posts whenI saw the schematic ....
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 19, 2011, 08:51 am
Yep, i'm in the process of calculating the correct resistor values for each of the colours right now. Thanks again for your help an of course one more quick question (lol there's always more questions right!!), can I swap the resistors to the Cathode side of the led's (would help when etching up my pcb -no jumpers etc). I've read that it does not matter which side of the led the resistor goes but was unsure in this case if this was ok?
Title: Re: Multiple leds on one arduino pin?
Post by: dc42 on Nov 19, 2011, 09:40 am
1. The BS170 isn't a good choice for the mosfet because it isn't logic level. Fig 1 on the data sheet http://www.fairchildsemi.com/ds/BS/BS170.pdf (http://www.fairchildsemi.com/ds/BS/BS170.pdf) suggests that its performance with 4v to 5v gate drive will be marginal. If you only want to switch up to 500mA, you could use a bipolar transistor (not darlington) such as BC337 instead (use a resistor from Arduino pin to transistor base of about 180 ohms, and you don't need a pulldown resistor). For more than 0.5A, choose a logic level mosfet.

2. Yes you can put the resistors in series with the cathodes instead of the anodes.

3. A minor point: I would connect the 10k gate pulldown resistor from Arduino pin to ground, i.e. connect it to the other side of the 100 ohm resistor. That way, it doesn't reduce the gate voltage drive to the mosfet slightly.
Title: Re: Multiple leds on one arduino pin?
Post by: Grumpy_Mike on Nov 19, 2011, 09:43 am
Remember if you are going to use RGB LEDs then you can't put the resistor in the common line.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 19, 2011, 11:10 am
Hi dc42 and Grumpy_Mike thanks for the info, I will look into the BC337 as I have a few lying around. The RGB's I have do not have a common anode or cathode, they have 6 pins A & C for all three diodes so I guess i'm good for the resistors as I can treat them as separate leds.

I'll also adjust where I put the 10K as suggested or of course omit it in the case of using the BC337.

Thanks for all your replies.

Update: New Circuit should look like this?
Title: Re: Multiple leds on one arduino pin?
Post by: CrossRoads on Nov 20, 2011, 03:20 am
Yup, that work too. Electrons don't really care.

What's the part number of the RGB LED with the seperate sets of leads?
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 20, 2011, 10:16 am
Hi again CrossRoads,

The Led's I'm gonna be using I found on Ebay Here:
http://www.ebay.co.uk/itm/30-PCS-PLCC-6-5050-3-CHIPS-Manual-Control-SMD-RGB-LED-/370361528889?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item563b447239 (http://www.ebay.co.uk/itm/30-PCS-PLCC-6-5050-3-CHIPS-Manual-Control-SMD-RGB-LED-/370361528889?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item563b447239)

But I actually bought them cheaper here:

http://www.ebay.co.uk/itm/50-pcs-RGB-PLCC-6-5050-3-CHIPS-SMT-SMD-LED-Light-/380366342281?pt=UK_AudioElectronicsVideo_Video_TelevisionSetTopBoxes&hash=item588f99c889 (http://www.ebay.co.uk/itm/50-pcs-RGB-PLCC-6-5050-3-CHIPS-SMT-SMD-LED-Light-/380366342281?pt=UK_AudioElectronicsVideo_Video_TelevisionSetTopBoxes&hash=item588f99c889)

They took about a week to arrive.
Title: Re: Multiple leds on one arduino pin?
Post by: dc42 on Nov 20, 2011, 10:37 am
The specification of the LEDs on that first link suggests that the maximum continuous forward current is 20mA, and 30mA is the peak rating for short pulses (the second link doesn't give any current ratings). So I suggest you choose the series resistors for 20mA per LED, unless you know that your LEDs are rated at 30mA continuous. The BC337 is likely to drop 0.2v or a bit more and you can allow for this in your calculations. You may find that the red one has a lower voltage drop and needs a higher value resistor.

I have a couple of similar LEDs in 6-pin mini-DIP packages, which I think are probably these http://www.rapidonline.com/Electronic-Components/Full-colour-6-pin-LED-ndash-Chameleon-71502 (http://www.rapidonline.com/Electronic-Components/Full-colour-6-pin-LED-ndash-Chameleon-71502). Unfortunately the lead spacing is 2mm rather than 2.5mm so they won't fit in a breadboard or stripboard.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 20, 2011, 11:35 am
Hi dc42, yep after even more googlin'  on theses leds i had settled on resistors rated for 20ma I also intend to test a few for forward voltages etc just to make sure. I'll also most likely end up putting a higher rated resistor on the green as it tends to take over when mixing yellow (from experience of other RGB's). I've actually produced my own pcb to put these on (toner transfer method and ferric chloride etch) so they fit beautifully on the board. This was my first first experiment with SMT components and it has worked well in my tests.

Thank you for your help with this I really appreciate it and will post pics and maybe a vid when I'm finished on my blog.
Title: Re: Multiple leds on one arduino pin?
Post by: CrossRoads on Nov 20, 2011, 05:38 pm
Well, those will be bright at 20mA!
Luminous Intensity:
RED:6000mcd;
BLUE:5500mcd;
GREEN:6500mcd

Will have to adust resistors for the colors not only for even current draw, but perceived brightness
RED:1.8-2.4V;
BLUE:3.0-3.6V;
GREEN:3.0-3.6V

Figure on calculating current based on the lower voltage drop too, for example with 5V source, 0.5 across a transistor, and 120 ohm resistor:
(5-2.4-.5)/120 = 17.5mA
(5-1.8-0.5)/120 = 22.5mA  << so a higher value resistor is needed

Similarly for a 50 ohm resistor:
(5-3.6-.5)/50 = 18mA
(5-3.0-0.5)/50 = 30mA  << so a higher value resistor is needed

and the data says that at 30mA
*Pulse width?0.1msec duty?1/10

Also, many datasheets (not found for this one) say that the life expectancy of LEDs drops when they are driven at the  higher currents.

Looks like 1.8mm pitch on the pads, very workable by hand (vs 0.5mm on the FT232RL chips!)
Title: Re: Multiple leds on one arduino pin?
Post by: CrossRoads on Nov 20, 2011, 05:41 pm
The 2nd link shows different specs




Quantity:50pcs

Emitting Colour:Red/Green/Blue

Forward Voltage:3.4~3.6V

Luminous(MCD):
Red 1000~1200
Green 3000~4000
Blue 1000~1500

Not nearly the brightness, probably why they are less expensive.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 20, 2011, 11:08 pm
Hey CrossRoads, great info thanks. I'll get calculating straight away.

I'm not overly worried about the brightness especially with 10 on each board.

I'm looking at running around 12 to 14 of these boards using shift registers. Am I gonna need a high current power supply or am I right in thinking that the transistors are doing the work?
Title: Re: Multiple leds on one arduino pin?
Post by: dc42 on Nov 20, 2011, 11:25 pm
Looks like you have a maximum current consumption of 10 x 20mA per colour per board, total 200mA (which is just fine for a BC337 to switch). Times 3 for the colours and you have 600mA total per board. Multiply that by 14 and you get 8.4A. So yes, you will need a high current power supply. One possibility is a standard ATX computer supply.

It would be easier to use higher voltage and lower current. If the LEDs drop 3.2v each, then instead of 10 led/resistor combinations in parallel, you could have 2 sets of (5 leds in series + one resistor). This would drop around 16v, so you would need (say) a 20v supply to drive it, and drop 4v in the series resistor. But it would consume 40mA per colour per board instead of 200mA. That brings the total power requirement to 1.68A at 20v, which is more manageable than 5v 8.4A.

Another option is 5 parallel groups of 2 leds in series, which would need about 9v @ 4.2A. If your boards had 12 leds instead of 10, you would have even more options, i.e. 12x1, 6x2, 3x4, 4x3.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 21, 2011, 08:32 am
Thanks dc42, I think a big revision is order, but its good to learn. I do have a spare ATX  power supply but it is a little unsightly, so maybe a trip to Ebay is order to source a possible supply.

Can't thank you enough for your help.
Title: Re: Multiple leds on one arduino pin?
Post by: Grumpy_Mike on Nov 21, 2011, 09:43 am
The transistors just switch. The power supply gives them something to switch.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 21, 2011, 12:48 pm
Hey Grumpy_Mike, yeah felt a little stupid after asking and not thinking about it properly lol. Thanks.

Edit: So been thinking about what dc42 said and rummaging through my box of hoarded power supplies I have found an old laptop power supply rated at 20V 3.25A DC does anybody think this might be ok?

Edit 2: Final circuit being added below! (hopefully!!!!lol)
Title: Re: Multiple leds on one arduino pin?
Post by: Grumpy_Mike on Nov 21, 2011, 11:12 pm
Add up the volts drop, I think there are too many LEDs. Anything with a current limiting resistor under 50R is pushing it for constant current like behaviour.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 22, 2011, 12:08 am
Ahh ok so green and blue look ok but red need a rethink?
Title: Re: Multiple leds on one arduino pin?
Post by: Grumpy_Mike on Nov 22, 2011, 12:23 am
No other way round, green and blue have bigger forward volts drops so you reach 20V with less LEDs than the red.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 22, 2011, 01:50 am
Awww man thought I had it!

Ok so the LEDs in my circuit:

Blue Vf = 3.1V:
So 3.1 x 5 = 15.5v

Green Vf = 3.07V:
So 3.07 x 5 = 15.35V

What am I missing?

Title: Re: Multiple leds on one arduino pin?
Post by: Grumpy_Mike on Nov 22, 2011, 10:22 am
Quote
What am I missing?

The fact that on that schematic you showed 10 LEDs in series not 5. This changes the maths.  :)
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 22, 2011, 05:27 pm
Oh I thought I had done the red as 10 in series and the blue and green as 2 x 5 series each, I will check!

Edit: I've check my circuit and the red led's have 10 in series and the blue and green have 2 x 5 led series in parallel each.
Title: Re: Multiple leds on one arduino pin?
Post by: dc42 on Nov 22, 2011, 10:38 pm
The green and the blues look ok, but the voltage drop across 10 red LEDs is too close to 20v for the series resistor to regulate the current well enough. Go for two chains of 5 red leds too.
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 23, 2011, 08:21 am
Thanks dc42 so should be good with this final schem!
Title: Re: Multiple leds on one arduino pin?
Post by: Grumpy_Mike on Nov 23, 2011, 09:45 am
Yes looking good.  :)
Title: Re: Multiple leds on one arduino pin?
Post by: dutchboy on Nov 23, 2011, 05:42 pm
Okey dokey, off to produce a few pcb's. Can't thank everyone enough for your patience and help.