4

I am using msp430g2553 microcontroller and a 4x4 HC543 keypad. I am using Energia IDE. I have connected the keypad from pin 2 through 9. My code is as follows:

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}

void loop(){
  char key = keypad.getKey();

  if (key){
    Serial.println(key);
  }
}

However I am unable to get an output at the Serial Monitor. I am especially confused if I am using the right pin configuration.

I have downloaded the Keypad.h library from Arduino website and imported it in Energia. Can this be a problem? Since all the functions (like makeKeymap and getKey) related to Keypad.h are properly colored.

1 Answers1

1

Could you try this?

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

josejos41
  • 35
  • 2
  • This is a very limited suggestion, as this will only pivot the table of keys, whereas the OP gets no output at all. Conversely it's considered good manners to supply some reasoning as to why you think it will help, especially on old questions (like this one) where the issue has been open for a long time. – Asmyldof Mar 25 '16 at 10:13
  • It also wouldn't make any difference to the lack of anything on the serial monitor. Changing the pins in this way is equivalent to diagonally mirroring the key map. – Tom Carpenter Mar 25 '16 at 11:19