Using a Nano so not many io available. I want to use 20 buttons, to select stepper positions.
Want to use a keypad matrix 4x5, and multiplexer 74HC165.
Question1: Is there a example sketch out there that uses MAX32 and keypad matrix?
Question2: How ( or do I need) to use the 74HC165.. Or does the button library cover the multiplexing somehow.
Hi Railroader
Thanks for your input. Have done some Googling and did not manage to locate anything on using the Matrix and multiplexer with MT.
Will consider changing boards. Maybe go to Uno or Mega. With plenty of pins.
Checked thru the documentation on MT Buttons. There is mention of matrix but no examples in use etc.
Thnks
The 74HC165 isn't a multiplexer but simply a shift register (parallel in -> serial out ). But you can use it to save input pins.
There is an example with a matrix. But unfortunately it is only 4x4 and it uses an I2C expander (PCF8574) to save pins. But it could be a better start than the example you linked. With two PCF8574 it should be fairly easy to extend the example to a 5x4 matrix. ( maybe worth an additional example with >16 buttons ... )
As already stated, the HC165 is only pi-so shift register. I would recommend to use a I2C IO expander. That needs the least Nano pins (only 2 ).
The library itself does no multiplexing. That has to be done in the callback ( see the example linked above - it is a matrix example).
The UNO does not have more IO pins than the Nano. With an Mega it would be possible without IO-expander - even without multiplexing at all. But the I2C solution would fit for a Nano too ( only 2 pins ), and if the rest of the Nano pins is sufficent for your project, I don't see you need to switch to a Mega.
[EDIT] There is also the PCF8575, which is a 16-bit IO expander. So you need only one I2C device for your matrix. The PCF8575 is available as breakout board for easy connection.
To extend it from 4x4 to 5x4 you need only one pin more - maybe possible to use a pin from the Nano directly. So you need 3 Nano pins and one PCF 8574 for your keypad ( and a small extension of the example ).
It's up to you which HW version you prefer