Is it possible to use MCP23017 I2C 16 port expander and 4x3 keypad?

I'm trying to set up the MCP23017 I2C 16 port expander to capture presses on a 4x3 membrane keypad. However, I'm a bit lost as to how to physically hook these items together and also a bit confused as to how I would implement the code.

I currently have the GPIOB side of the MCP23017 mapped as inputs and I've successfully captured state changes of a push button, confirming the change by illuminating the corresponding LED on the GPIOA bank.

Now I want to swap out the push buttons for the keypad, but I'm not sure how it should be connected.

I've downloaded and attempted to get the Keypad_I2C examples from working, but they seem to be written for a PCF8574 - not sure if my MCP23017 is a drop-in replacement for that.

I haven't had much luck getting the chip to respond to state changes on the keypad.

  1. Is it even feasible to do what I'm attempting?
  2. If so, how do I need to physically connect the 4 row and 3 column pins to the MCP23017?
  3. Should the Keypad_I2C be working for me or do I need to write something from scratch?


I see there's a library for the MCP23016 but I also have a few 17's handy so was hoping to use those. Did you manage to get this going in the end?