Go Down

Topic: MCP23017 + Keypad w/ Arduino Nano - One Bank not responding to mcp.digitalWrite (Read 87 times) previous topic - next topic

PanzerKnacker77

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:

 
Code: [Select]
#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] = {
  {'1','4','7','*'},
  {'2','5','8','0'},
  {'3','6','9','#'},
  {'A','B','C','D'}
};
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( );
  mcp.begin();
  customKeypad.begin( );        // GDY120705
  Serial.begin(9600);
  for (int i=8;i<16;i++)
  {
    mcp.pinMode(i, OUTPUT);

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

  if (customKey != NO_KEY){
    Serial.println(customKey);
  }

 if (customKey == '5') {
  digitalWrite(A0,HIGH);
  mcp.digitalWrite(8,LOW);
  delay(200);
 }
  else
  {
    digitalWrite(A0,LOW);
      mcp.digitalWrite(8,HIGH);
  }


}



Thanks a lot for your support!

Elias

PanzerKnacker77

it seems that I have the same problem that was asked here :smiley-confuse:
http://forum.arduino.cc/index.php?topic=264152.0

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

pylon

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

Quote
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.

Go Up