Sunday, September 8, 2013

Control 6 LEDs with 2 pins using Gracieplexing

In my last post I explained Gracieplexing and demonstrated how to control 2 LEDs with 1 pin, an explained how 2 pins could be used to control up to 8 LEDs.  In this post I'll explain how to control 6 LEDs, and later do a third posting about a circuit to control the full 8 LEDs along with C code for Arduino-compatible MCUs to manipulate the 8 LEDs.

The following matrix describes how the state of the 2 MCU pins will map to the LEDs:
Using two pins independently us to control LEDs 1 through 4; the extra complexity is in controlling LED 5 and 6.  By wiring the extra 2 LEDs in opposite polarity between the two MCU pins, when one pin is high and the other low we will turn on LED5, and LED will turn when the pin polarities are flipped.  If we stopped there, we would have a problem though.  Turning on LED5 would also turn on LED3.  We can solve that problem by adding a standard (~0.6v) diode in series with LED3.  Using red LEDs with a Vf of 1.8v, a total of 2.4v will be required to turn on LED3, but when LED5 is on there will only be 1.8v.  However when the cathode of LED5 is not pulled low, the voltage will rise and turn on LED3.  In addition to the schematic I've done a Fritzing breadboard layout for connecting to an MCU.
And here's a video demonstration on a breadboard:

1 comment:

  1. can you post the schematic too, its kind of hard to understand on breadboard for folks like me who are stuck with schematics- Thanks

    ReplyDelete