2

I want to know the button pressed in the Serial-Monitor in Arduino-Ide. I am using Arduino-Uno Board and I have connected the MCP23017 IC via I2C Connection with Arduino-Uno board. I have connected the 5*5 Push-button Matrix with the pins of MCP23017. I am using the joe young/arduino_keypads library.I am not able to view the button pressed in the Serial-Monitor.

#include <Keypad_MC17.h>
#include <Keypad.h>        
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#define I2CADDR 0 
Adafruit_MCP23017 mcp_1;

const byte ROWS = 5;    // five rows
const byte COLS = 5;    // five columns

//define the symbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','4','5'},
  {'6','7','8','9','A'},
  {'B','C','D','E','F'},
  {'G','H','I','J','K'},
  {'L' ,'M','N','O','P'}

};

byte rowPins[ROWS] = { 15 , 14 , 13 , 12 , 11 };     //connect to the row pinouts of the keypad
byte colPins[COLS] = { 10 , 9  ,8 , 7 , 6 };        //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(){

  Serial.begin(9600);
  Serial.println("Program Started" );

  //Begin I2C Devices
  Wire.begin();
  Wire.beginTransmission(0);
  if (Wire.endTransmission(0) == 0) Serial.println("I2C Device Not Found 0x00");
  else Serial.println("I2C 0x00 Connected Successfully");
  mcp_1.begin();

  // Begin Keypad Device
  customKeypad.begin( );

}

void loop(){
  char customKey = customKeypad.getKey();
  if (customKey != NO_KEY) {
    Serial.println(customKey);
  }

}

underscore_d
  • 6,309
  • 3
  • 38
  • 64
Paulson Raja L
  • 379
  • 2
  • 11
  • what is the issue? the keypad or your serial connection? – Piglet Nov 15 '19 at 12:01
  • why is the i2c address 0? try to run the example that comes with the lib befor you attempt to change it. why do you attempt to communicate with the MCP? that's done by the library – Piglet Nov 15 '19 at 12:10
  • @Piglet Sir, got the task completed, the serial connection was the issue. – Paulson Raja L Nov 20 '19 at 18:12

0 Answers0