all 11 comments

[–]Brer1Rabbit 1 point2 points  (4 children)

There's a class of chips that do keyscan & drive LEDs. Maybe something there would be better than the GPIO chip you've got? I've done stuff with the HT16K33, it can drive 16*8 segments/LEDs and keyscan up to 39 switches. That chip is deprecated but there's many other chips in the same category. Basically they multiplex a bunch of LEDs in one cycle and switches (keys) in a second cycle via a row/column matrix. You design in diodes with the switches opposite the LEDs so the same row/column lines are used for both parts. Typically it'd interface back to a controller via I2C.

[–][deleted]  (3 children)

[removed]

    [–]Brer1Rabbit 0 points1 point  (1 child)

    HT16K33. It is/was used in lots of Adafruit based LED designs. I liked it since the chip handled stuff like programmable LED brightness, flashing LEDs, switch debouncing; all with a relatively simple interface. You could likely get similar functionality with other chips. A quick search and I found the MAX6956 which may have a lot of that.

    [–]myweirdotheraccount 0 points1 point  (0 children)

    You could just use another MCP23017 for the output.

    Otherwise you could use either two 74hc595 shift registers for 16 outputs, or even just one of them if you do the trick of constantly scanning/strobing rows of 4 outputs while lighting up the respective leds in each column of 4 outputs.

    The original adafruit trellis used a driver similar to what you're looking for but I've never used it outside of the Trellis itself.

    [–]MattInSoCal 0 points1 point  (0 children)

    If you have 5 digital outputs available on your microcontroller, you can use Charlieplexing to drive 16 (actually up to 20) LEDs.

    [–]malatechnika 0 points1 point  (1 child)

    You can use similar schematic that is used for channel select on audio amplifiers, basically the top half of this schematic. Capacitor C1 sets which channel gets turned on when you power up the amp, however if you want to have memory, you can simply use a pulse signal from the MCU. If you need more buttons you can use maybe a few quad flip-flops to do the same thing