I have only six GPIO to control a piezo buzzer and 6 LEDs and read 6 buttons...
Would multiplexing the 6 LEDs/buttons in a 2x3 matrix work like this (i.e. 5 pins for the 6 LEDs and buttons, one dedicated pin for the buzzer):


simulate this circuit – Schematic created using CircuitLab

Driving the LEDs with "regular" multiplexing, i.e. row as output high, column as output low. Scanning the buttons by setting row as output high and column to input with pull-down.

Drawback: pushing the button causes the LED to go off, increasing current - not be a problem with low-current LEDs.

Am I missing something? Could it be improved? Are there any implementations "out there"?


Scanning the buttons by setting row as output high and column to input with pull-down.

The LEDs would still be forward biased and could be recognized as if a button was being pressed. It's borderline that this will work effectively.

When driving the LEDs, keep the row as a driver and the column as an input (with a pull down) but, when scanning the switches, reverse bias the LEDs by driving the column high and having a 10k to 100k pull down on the rows (now set as inputs): -

You could even put a diode in series with the switches to stop the LED being "blanked" when the switch is pressed. Clearly when scanning the switches the LED gets turned off for a small length of time but this should be unnoticeable if scanning switches / driving LEDs at a fast rate.

enter image description here

It should work at logic levels as low as 3.3 volts but check the input threshold high limits in the data sheet are not greater than about 2.6 volts.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.