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] = {
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(){

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

  if (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.

  • \$\begingroup\$ put Serial.println("Hello World"); after Serial.begin(9600); just to make sure it's not unrelated to your code. \$\endgroup\$
    – vicatcu
    Aug 22, 2015 at 16:03
  • \$\begingroup\$ Also the example at playground.arduino.cc/Code/Keypad has if (key != NO_KEY) rather than if(key) \$\endgroup\$
    – vicatcu
    Aug 22, 2015 at 16:06
  • \$\begingroup\$ Did this end up with a resolution? \$\endgroup\$ Mar 11, 2016 at 5:13

1 Answer 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

  • \$\begingroup\$ 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. \$\endgroup\$
    – Asmyldof
    Mar 25, 2016 at 10:13
  • \$\begingroup\$ 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. \$\endgroup\$ Mar 25, 2016 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.