Go Down

Topic: Will this work? Run 2x as many LEDs with same current, using tri-state logic. (Read 1 time) previous topic - next topic


Hey guys,

My latest project involves using an Arduino Pro Mini to animate 15 leds.  These 15 leds consist of a 10-segment bargraph, and 5 individual leds.  For simplicity's sake, I wanted to avoid using additional chips or transistors to drive my LEDs, so the Pro Mini's regulator would need to supply all the current.  The voltage regulator on the Pro Mini is kinda wimpy though, and after deducting the current the microcontroller uses, you've only got around 100mA to work with.  I allocated 50mA to the 5 individual LEDs, which left me with 50mA for my bargraph.  But the leds in the bargraph aren't particularly bright, so when I run them at 5mA, they're kinda dim. 

If only I could double the current, they'd shine brightly!  But how do do that?

I knew that it was possible to run two LEDS at the same brightness without doubling the current by wiring them in series.  Then, rather than wasting 3.3v of your 5v as heat, you can use a smaller resistor and turn most of that excess energy into light.  I'd also read about Charlieplexing, which is using the tri-state logic of a microcontroller... high, low, and input, to drive a larger array of leds than you could normally using the same number of pins. 

That is what led me to this solution.  I'm not sure if it'll work since I'm still new to this stuff, but I think my logic is sound:

Here's the theory of how it should operate: 

Each of the 8 pins can be put into a high, low, or input state.  In input state (represented by the - symbol below), the pin is effectively disconnected from the circuit, as in charliplexing. 

To light the first led, you would set the pins like so: 10------
To light the second led, you would do this: -10-----
And to light the first and second leds, you would do this: 1-0-----

Now you may notice a problem.  If all of the resistors have the same value, then if you're putting 10mA through the first two leds when they're lit simultaneously, then because the voltage drop of the second led isn't there when you light just one of them, you'll be putting much more than 10mA through the LED when you light only one of them.

Using a bit of algebra though, I found a solution to that issue as well.

Imagine the first three resistors in the schematic are labeled A B and C.  Now, let's say you want to put 10mA through each LED, and each LED has a forward voltage of 2.1 volts.  For a single LED with a 5v source, you need a 330 ohm resistor.  And for two leds, you would need an 82 ohm resistor.

So, we know that:
A + B = 330
B + C = 330
A + C = 82

Which means:
A + B = B + C

And so:
A = C

That being the case, if A + C = 82 and A = C, then A and C must be 41. 
And now that we know the value of A,  we can subsitute that into our first equation, A + B = 330, and we get B = 289.

In other words, if we calculate two resistor values X, and Y, where X is the vlaue needed for a single LED, and Y is the value needed for two leds, then we should use the following resistor values:
A = Y/2
C = Y/2
B = X-A

And this will give us the correct total resistance to provide 10mA to each LED regardless of whether we have one or two LEDs in a particular string.

Another potential pitfall you may have noticed is that when a pin is set to ground, you may have two pins to either side of it which are sinking current into it.  Because of this, you'll need to do your calculations such that each LED isn't using more than 10mA.  So for 8 leds, you could use 40mA total, where each led is getting 10mA. 

The only other issue I see is that if one LED goes out, then the other LED in the pair will not light when you try to light both.  But since the LED which is not burnt out will still light if lit alone, it wouldn't be difficult to figure out which one burnt out.

Anyway, let me know what you think.  I'm not yet good enough with this stuff to be sure that this will work.  I think it will.  I think a little juice will flow from a high pin to an input pin, but not enough to actually light the led, which is why Charlieplexing works, I think.


I'm building a prototype now, since I'm fairly confident I won't blow up my Arduino if it doesn't work.  I did notice when I added leds 9 and 10 that looping back to the first LED wasn't gonna work, but I think routing them to Gnd via the smaller resistor will.  And in the case of 8 leds, I think routing the last led to Vcc via the smaller resistor may have worked as well. 

Also I may be able to tie the first LED to Vcc thus saving a pin and requiring only 9 pins to animate 10 LEDs.  I'm not totally sure that works out yet, but since with this setup you should only need to have half the pins high to light them all, maybe it will.


Well I built the prototype, but it's behaving a bit odd. 

When I set the pins so the ones between each pair of LEDs is in input mode, and I set the others to be high or low as needed, with the leds on either end being tied to Vcc and Gnd, I get a pattern like so:
light, light, dim, dim, light, light, dim, dim, light, light

And I can't explain what could be causing it.

The leds which point from the Vcc end towards the Gnd end are the ones which are brighter.  The ones pointing the opposite way are dimmer.  I suspect the Vcc ones being brighter is due to there being two more of them.  But I don't see how the Vcc and Gnd connections could be having an effect on the whole set of LEDs.


I have read your description several times and for the life of me I can't tell what you are trying to do. It seems like the electrons agree with me.

Get your meter out and measure what you have.


Well, you know how you can wire two LEDs in series, and get more bang for your buck?  Where you can use a smaller resistor in series with them, because you're wasting less power?

I'm trying to do that with a 10 segment bargraph so I can light it with 50mA, but make it appear as bright as if I had 100mA to work with.  And I still want to be able to selectively turn the LEDs on and off.

I'll draw up a better schematic after I do a few more tests.  I have some ideas about where I may have screwed up.

Go Up