MCP23017 + Keypad w/ Arduino Nano - One Bank not responding to mcp.digitalWrite

Hi All, this will be my first question, also please bear with me.

I am working with an Arduino Nano and attached an I/O-Expander (MCP23017) with I2C. I connected a Keypad to GPA-Pins (0-7) and used the Keypad_MC17 and Adafruit_MCP23017 libraries.

Now, the Keypad is functioning ok, I am able to read the inputs thru the serial monitoring. The problem I am facing (and I already checks for similar problems in many forums), is that my second bank (GPB) is not switching any of the connected LEDs or Optocouplers.

I checked that the GPB is changing the voltage state according to the mcp.pullUp I defined in the code (I tried both).
The RESET Pin from the MCP23017 is connected to 5V through a 100KOhm.

Again, I don’t see any response from the Ports GPB (Pins 8-15). The readings from the keypad are ok.

here is my code:

#include <Keypad_MC17.h>
#include <Keypad.h>        // GDY120705
#include <Wire.h>
#include "Adafruit_MCP23017.h"

#define I2CADDR 0x20
Adafruit_MCP23017 mcp;

const byte ROWS = 4; //four rows
const byte COLS = 4; //five columns

char hexaKeys[ROWS][COLS] = {
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad_MC17 customKeypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS, I2CADDR); 

void setup(){
//  Wire.begin( );
  customKeypad.begin( );        // GDY120705
  for (int i=8;i<16;i++)
    mcp.pinMode(i, OUTPUT);

void loop(){
  char customKey = customKeypad.getKey();

  if (customKey != NO_KEY){

 if (customKey == '5') {


Thanks a lot for your support!


it seems that I have the same problem that was asked here :confused:

But I can’t find any conclusive finding. Is it because the register is closing by getKey() before allowing the other output pins of the B-Bank to be switched?

Thanks in Advance

I guess the important information in that thread is this one:

Because the I2C chip's registers must be written all at once, these functions are needed so that the operation
of the keypad can be kept separated from the operation of the spare pin(s).

That means you must not use the Adafruit library to access the other pins but the function of the keypad library.