Reversing polarity of multiple LEDs using AVR microcontroller

Thread Starter

undazeraw

Joined Oct 23, 2014
4
I want to control multiple LEDs at the same time using a microcontroller. The LEDs will all be enclosed in 3d printed blocks with contacts on the top and the bottom.There can be any number of LEDs connected at a time (limited only by either the power supply - 3A or the number of blocks that I can print before getting tired of printing them all). When stacked, the blocks can be orientated in different directions, meaning the polarity of the LEDs can be reversed from one block to another. A base plate will supply the power to the LEDs when they are stacked onto it.

If all LEDs were orientated in the same direction then I could just connect them to a MOSFET to supply power to them all from one control pin and they would be either lit or unlit. What I want to be able to do is reverse the polarity of the supply on the base plate so that when some blocks are reversed, it will be possible to alternate which LEDs are lit. A DPDT relay would be the easiest choice for reversing polarity at the possible current levels, but I am wanting to keep the base plate as thin as possible... thinner than any relay I've encountered in the past.

I am using a microcontroller so that I can have a mode selection to have the LEDs either constantly on, alternating the lit LEDs (by reversing polarity), fading (using PWM) or on a timer so that they stay on for a set period of time before turning off.

The 3d printed blocks will have limited space inside and will only be able to contain the LED and a current limiting resistor. All of the LEDs will have to be connected in parallel as there is an unknown number and limitless ways of stacking them.

Would the best way to implement this be to use an H-bridge? I have never thought of using one for anything other than motor control before, but at the moment that is the only way I can think of unless someone knows of thin (preferably DIP style packaging) SSRs which can handle the current.

Any suggestions would be greatly appreciated.
 

spinnaker

Joined Oct 29, 2009
7,830
That is one really long and confusing post. Can you boil it down into a few sentences?

The best I can figure is you are talking about CharliePlexing. Look it up and see if that works.
 

Thread Starter

undazeraw

Joined Oct 23, 2014
4
Sorry for the length. I was trying to include as much information as possible.

I am using many LEDs, but they are all connected in parallel to one source. The LEDs can be connected in either orientation, so in effect it is like a 2 LED Charlieplex. The issue I have is that there can be any number of LEDs connected to the one pair of outputs from the microcontroller, so I need a way of supplying far more current than the micro can handle.

Essentially, what I am looking at is a high current tri-state buffer to connect to the tri-state outputs of the micro.

Does such a thing exist in a small form, or does anyone have a circuit to make one?
 

Papabravo

Joined Feb 24, 2006
21,225
I doubt that the device you want exists or is readily available. My only confusion is that without a schematic I really don't have a firm idea of what you are talking about or what you want to do. You do know that current only goes through an LED in ONE direction. So with one source, all the LEDs connected in the correct direction will light and the rest will be OFF -- FOREVER!

Maybe you are thinking of an H-Bridge. Then, at least, you could alternate ON with OFF and OFF with ON. Is that what you had in mind?

https://en.wikipedia.org/wiki/H_bridge
 
Last edited:

Thread Starter

undazeraw

Joined Oct 23, 2014
4
The one source I am using is a pair of microcontroller pins. These pins can be either on, off or high impedence. It was clear in my mind when I was writing it because I have been thinking about it, but reading my post back I can see I didn't make it at all clear for anybody else reading it.

All I had come up with so far was an H-Bridge, but I have only ever used them before for motor control and was wondering if there was a better/different way.

I have done various circuits like LED cubes and spheres using shift registers to control up to 1536 LEDs individually, and short strings of Christmas lights with 5 RGB lights (15 LEDs) using Charlieplexing on an 8-pin micro. At some point, I expect I will end up trying to Charlieplex much higher loads than a single LED at a time, so I was hoping to find a solution I could come back to in future for such a circuit.
 

Thread Starter

undazeraw

Joined Oct 23, 2014
4
Thinking about it more, the only benefit of using Charlieplexing is for keeping the component and pin count down, so going for an increased power output by adding components defeats the point entirely. Where I need to control higher currents for more or beefier LEDs, I may as well just use driver chips.

I have some H-Bridges lying around from a robot chassis that never got finished, so I will probably just go with them for the current project.
 

Papabravo

Joined Feb 24, 2006
21,225
Ahhh. You want to use the pins on the microcontroller to control the flow of current. Do NOT use them to source and sink LED current.
 
Top