Matters of current and voltage are still somewhat of an enigma to me, but I would be grateful if anyone can spare a moment to teach me something! I have two questions, one about current / resistance and the other about external power and the arduino.
Here is what I want to do :
I have 48 LEDs that have a recommended continuous current of 15 - 18 ma, and a voltage range of 3.0V to 3.2V.
My power supply yields 5.27V with the ability to sustain a continuous 8A.
I want to divide them into 12 groups and have each group of 4 LEDs controlled by an arduino pin.
Presently these LEDs are soldered in parallel with two long wires connecting each group back to my robot, similar to this example with 8 LEDs :
and determined that for the LEDs I'm using, the voltage drop is 1.53 per LED.
Multiplying 18ma x 4 and I get a 72 ma draw, so to determine the resistor, ( 5.27V - 1.53V ) / 0.072 = 50 ohms. Did I do this correctly?
The LEDs will light with a 47 / 100 / 220 ohm resistor. I just don't want to burn them out.
The second question is, what is the best practice in circuit design if I want to control these from an arduino pin and use my external battery above ( 5.27V 8A )? If I recollect, the pins on the arduino will output 40 ma, but if I'm consuming 72 ma I reckon direct wiring isn't the method. Would I use a transistor or MOSFET for each light segment?
Use a single MAX7219 to control all of them.
Wire up as a 6x8 matrix. Anodes connect to Segment Pins, Cathodes connect to Digit Pins.
Can control in any matter you want - individually, by columns, by rows, etc.
Simple matter of writing data to 8 registers to the On/Off states of the LEDs.
When wiring up leds in parallel, you should use a series resistor per led, not one for the whole group. Otherwise, the leds will not look evenly bright (no two are identical, even if manufactured in the same batch) and if one led has a lower forward voltage tban the others, your low value single series resistor may not protect it from overheating.
40mA is the max for an Arduino output, but you shouldn't design your circuit to use the max. Stick to 20~25mA for safety and long life. You are correct about the need for transistors. I suggest bc337 with ~1K for the base. Or get a couple of ULN2003. They contain 7 transistors (Darlington pairs) in one package
Let me add a few photos of my project for clarity...
Thanks for the info guys!
@PaulRB: If I had it to do again I'd give each LED a resistor, but at the time of my reading up on it I'd already soldered this up. I figure I can chunk 48 LEDs now, or try to salvage this circuit LOL. Four LEDs are wired in parallel and embedded in semi-transparent orange plastic. You cannot see them directly, so having one brighter or dimmer isn't really a problem - I just want the housing to glow and the LEDs not to burn up. Granted that I will follow Best Practices next time, have I properly determined a safe resistance value with my formula? I actually want to learn the math of this.
@CrossRoads: I was excited thinking I had one of these in my box already haha. Thank you for that, I will definitely want one of these to drive the 8x8 display and segmented displays I have. Would you still use one for the project above? I have a Mega going into the robot with plenty of pins unobligated. I'll order a MAX7219 and learn it. Somehow I thought 12 transistors for switching would be simpler and most cost effective, but it looks like I can get a MAX7219 for $2 to $6 from China. Just need to wait 3 weeks ugh
Your formula for the series resistor is correct. Of course the current through each resistor would be only 18mA if you had one per led. The other component that would drop some of the supply voltage would be the transistor (probably only around 0.3V) or Darlingon (more like 0.7V). Even the Arduino output's internal circuitry will drop some voltage if you run an led directly from it, drawing or sinking, say, 20mA.
Individual series resistors are important for long life, not just even brightness. If one of your leds has a significantly lower forward voltage than the other 3, it will take much more than its fair share of the current, exceeding its maximum and shortening its life. Once that blows, the current flow will be less, exposing to other 3 leds to excess voltage and... well you can guess where that story ends!
Be warned that most max7219s on ebay are fakes. If you pay 10$/€/£ from a major American or European supplier, that will probably be a genuine Maxim. Having said that, myself, Crossroads and many others have had few/no problems with the cheap fakes, but some have.
When wiring up leds in parallel, you should use a series resistor per led, not one for the whole group. Otherwise, the leds will not look evenly bright (no two are identical, even if manufactured in the same batch)
Same thing with a resistor on each LED, unless you play with the values of each one.
steinie44:
Same thing with a resistor on each LED, unless you play with the values of each one.
True, I'm sure, but surely the difference in current and brightness will be barely noticeable? By contrast, if I understand the theory, a small difference in forward voltage can lead to a large difference in current and failure of the led when using a single series resistor with parallel leds. Semiconductors don't obey Ohm's law, the relationship between current and voltage is not linear, right? Plus, resistance drops with increasing temperature with most leds, I understand, making them vulnerable to thermal runaway. Please correct me on this if I'm wrong.
MAX7219 multiplexes the LEDs. From your pictures, I would suppose that you'd brighter all the time tho.
I'd go with some TPIC6B595, shift register with high current sink capability - 150mA per each of 8 outputs. Daisy chain a few together and let them sink the current.
I offer a board that supports up to 12 of them (designed for sinking current from 12V LED strips to make large 7-segment displays) that could be just what you need. Has a '328P chip also, plug on an FTDI Basic and its basically an Uno with shift registers. http://www.crossroadsfencing.com/BobuinoRev17/