Shared Anodes and Cathodes
Shared anodes and cathodes are a common technique used to control lots of LEDs with a small number of microcontroller pins. I’m going to talk about why share anodes and/or cathodes. Then I’ll show an example of shared anodes, an example of shared cathodes, and finally combine the two for some more impressive results.
Why share anodes and cathodes?
It scales really well. If there are no shared anodes and cathodes then to independently control N number of lights then you need at least N+1 anodes and cathodes. If there are shared anodes and cathodes then you need A anodes * B cathodes to run N LEDs. So for…
…16 lights you need 4 anodes and 4 cathodes.
…25 lights you need 5 anodes and 5 cathodes.
…256 lights you need 8 anodes and 8 cathodes.
…512 lights you need 8 anodes and 16 cathodes. (or 16 and 8, it’s your call.)
…17 lights you need 4 anodes and 5 cathodes. There will be some anode/cathode combinations with results I can’t predict.
Wiring the shared anodes and cathodes together
It occurs to me that in the video I put the resistors on the anodes. It makes no difference. As long as they are there to keep the LEDs safe, it doesn’t matter if they are before or after the LEDs.
Also please note the potentiometer in the bottom left corner of the schematic. I’m going to use the value from this potentiometer to change the behavior of the Arduino sketch.
I’ve include two sketches in the shared anodes and cathodes github project.
SharedAnodesAndCathodesA.ino will run either (a) four LEDs with shared anodes or (b) four LEDs with shared cathodes. The code is the same, the effect is exactly the opposite.
SharedAnodesAndCathodesB.ino will run 16 LEDs with four shared anodes and four shared cathodes, as described in the wiring diagram above and the video below. Speaking of which…
Printed circuit board
I’ve designed an arduino shield that cleans up all the wiring in the 16 LED demo. If you’re interested in having one (or more!) comment below and we’ll make it work.
RGB LEDs have four legs. Typically the long leg is the cathode and the three shorter legs are the red, green, and blue anodes. very quickly cycling between the three anodes will create many different hues.
This is a perfect case for using a shift register. Try it yourself!
Expand this idea far enough and you can build large displays. The very early classic Hercules monitors had gold and black colors in 720×350 resolution. 1080 anodes and cathodes? Easy! 😉
[products skus=’ELEC-0004, ELEC-0005, ELEC-0067, ELEC-0088, ELEC-0089, ELEC-0090′]