Introduction: Gugaplexing 24 LEDs Using 4 Pins

About: I like to make stuff. I'm more of a "learn as you go" type person.

I want to create a digital TicTacToe game using LEDs, pushbuttons, and a Digispark ATTiny85. Pins are a premium on the Sparky85's. At a minimum, I'd need 18 LEDs lit & 18 pushbuttons (9 for X and 9 for O). Shift registers would only use 3 pins and seemed like a suitable solution for either the LEDs or pushbuttons. I haven't seen anywhere that 2 different 74HC595 shift registers (1 for input & 1 for output) are controlled by the same SER (Data) & SRCLK (Clock) pins but with different RCLK (Latch) pins. The Sparky85 only has 1 MOSI (for SER) pin and 1 SCK (for SRCLK). I'm not a coding pro, but it seems like a challenge to use the same data pin for 2 different registers. Guess I need to find some more options.

Step 1: The Hunt Begins...

After a search for different solutions, I stumbled upon charlieplexing. Very interesting concept and new to me, but I'd need 5 pins for either LEDs or pushbuttons. Then, 1 single Instructable by cedtlab mentioned gugaplexing (GuGaplexed LED Heart)...and that was back in 2008. Still a lot of good info on the difference between charlieplexing and gugaplexing. I did a lot of searching around for more information on gugaplexing, but most posts/articles reference the EDN Article from 2008 (also attached original article photocopied). Unfortunately, they only show the logic table for 2 pins (or 4 LEDs). There was the 24-LED circuit so that helped some. Time to apply some critical thinking skills.

The total combinations possible for N pins with 3 different states is N^3 which gives us 2^3=8. The formula for available outputs is 2*N*(N-1) which only gives us 4 outputs for 2 pins. That meant there are some invalid states for all possible combinations, but I couldn't find anything to tell me what those states were. The table for the 2-pin gugaplexed circuit didn't have 1 pin high/low and 1 pin at Z (high impedance). My conclusion was that you need 2 pins in an output state (1/0 or high/low) and anything connected to a pin at Z (input state) would not work. So what does that look like???

Step 2: GuGaplexing and Beyond

The results of my critical thinking skills and horrible drawing abilities. Attached are the schematic and logic table for 24 LEDs. I don't need P3 to P4 or PR3 to P4 because I only need 20 lights, but I put them in there in case they help someone else out. Since I'm using RGB LEDs, I need 2 legs of the 4-legged LED to be biased in the same direction because they'll be common cathode or common anode. That's why the LED numbering is a little sporadic.

To get 1 LED to light, only 2 pins are in an active output state(high/low) and the other pins are in a high impedance input state. The same principle will work for 3x3, 4x4, 5x5, etc.

Well I hope this helps someone looking to X-plex the heck out of something!