Go Down

Topic: Will this work? Run 2x as many LEDs with same current, using tri-state logic. (Read 3542 times) 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.


Interesting - you can't use a fully-populated Charlieplex array because there will always be a shorter (in a voltage sense) path somewhere else if you try to drive 2 in series.  So you arrange that there are no short cuts (here one long loop) and you can drive 2 in series in certain places.

But this scheme limits which LEDs can be driven in series - however it doesn't limit which LEDs can be lit I think.  And you don't save any pins like Charlieplexing can - but you save upto 50% power/current in the right circumstances...

Here's a possible variation:  imagine you have 8 pins feeding the corners of a cube via resistors.  Every edge on the cube has an LED linking the appropriate corners.  By driving two neighbouring corners you can turn on one LED.  By driving two corners diagonally opposite on one face you could drive 2 LEDs in series and by driving diametrically opposite corners you get 3 in series.... There are many ways to orient the LEDs at each edge though - and it makes Charlieplexing look simple!
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Okay, I modified my test circuit to simplify things a bit, and I have drawn up a new schematic to show how it is constructed and what's going on:

I have six LEDs here, but when I drive the circuit with the pins states listed at the bottom of the schematic, the two leds in the middle are dimmer than the rest. 

I don't have a good understanding of current flow, but I think somehow the two leds at each end of the array are affecting the voltage potentials at pins 3 and 5 and that's leading to the reduced current flow across the two leds in the center.  I have absolutely no idea how to calculate what's going on though, or how to fix it.


I think with every other pin set to input mode, the circuit simplifies down to this:

I assume with this it's obvious where I've gone wrong, but I guess I don't know how to calculate the flow of current properly.  It looks to me like each path in the circuit has the same amount of resistance, and the same voltage drop, so I would assume each LED would get the same current.


I can't figure out how to analyze this.  I've been reading about ohm's law and ways to analyze how the current and voltage are changing, but the best I've been able to determine is that with 47 ohm resistors, in that last schematic, each pair of leds would be seeing 2.5 volts... if the circuits were unconnected.  But I can't find any information on how to determine how the voltage changes at the point where each pair of leds meets.  (pins 3 and 5)  I also cannot explain why the middle pair should behave differently than the pair on each end.


I'm trying to analyze the circuit with this method but I don't know how I'm supposed to integrate the voltage drop of the LEDs into the equations:


Okay, working with a simpler circuit, I think I'm supposed to add the voltage drop at each stage.  (Add, not subtract because the equations use electron flow so everything is backwards.)



I just spent an hour doing a page full of algebra solving three simultenous equations, and the solution I arrived at is I2 = 0, which I think means the second of the three meshes has no current flowing through it.  Which is impossible, because the LEDs are lit dimly, but only about 5mA dim, not 0mA dim.

I1 and I3 I calculated to have 8.5mA, which is what they should have if they were unconnected to the middle circuit.


Of course, if I ignore the math, and just go by my intuition, looking at the three euqations I came up with:

(a = i1, b = i2, c = i3)

95a + 47b = 0.8
47a + 94b + 47c = 0.8
47b + 94c = 0.8

And knowing that the higher the value before each variable, the lower the current in that circuit, I would guess that this is telling me that the circuit in the middle is getting half the current of the two outer ones.

However, why this is happening, is still a mystery to me, and even if I had solved the equations properly, it still wouldn't explain the why of it.


If you look at the circuit in reply 7 you will see that the resistor connected to pin 5 has the current from two lots of LEDs through it. All the other sets of diodes only have resistors with one lot of LEDs going through them. This means that this resistor drops more voltage than the others and so reduces the current through those LEDs.

but I don't know how I'm supposed to integrate the voltage drop of the LEDs into the equations:

use the super position theorem:- http://hyperphysics.phy-astr.gsu.edu/hbase/electric/suppos.html

(Add, not subtract because the equations use electron flow so everything is backwards.)

No it works the same with conventional current.


If you look at the circuit in reply 7 you will see that the resistor connected to pin 5 has the current from two lots of LEDs through it. All the other sets of diodes only have resistors with one lot of LEDs going through them.  This means that this resistor drops more voltage than the others and so reduces the current through those LEDs.

How do I determine how much voltage the resistor connected to pin 5 drops?

And what about the resistor connected to pin 3?  The current flowing through that has to pass through two sets of leds as well.


Oh and another thing... What you said about the resistor on pin 5 doesn't explain the results I'm getting.  If resistor on pin 5 is dropping more voltage than the other resistor, then shouldn't that affect both sets of leds which are passing current through it?  That's not what's happening though.  Only the middle two leds are dimmer.

If on the other hand, both the resistor on pin 3 and the resistor on pin 5 were dropping more voltage than the other resistors, then that would explain why the leds in the middle are dimmer, because the total voltage in their circuit would be slightly lower than the two on the outer edges.

But I still don't understand why 3 and 5 would dtop more voltage than the others, or how to calculate how much voltage they're dropping.

I'll take a look at that page you sent me a link to though.  I don't know what it's supposed to have to do with integrating LEDs into those other equations, but it looks like it may assist me with this resistor voltage drop calculation.


Nope.  Still lost.

Go Up