4
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ put Serial.println("Hello World"); after Serial.begin(9600); just to make sure it's not unrelated to your code. \$\endgroup\$
    – vicatcu
    Commented 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
    Commented Aug 22, 2015 at 16:06
  • \$\begingroup\$ Did this end up with a resolution? \$\endgroup\$ Commented Mar 11, 2016 at 5:13

1 Answer 1

1
\$\begingroup\$

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

\$\endgroup\$
2
  • \$\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
    Commented 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\$ Commented Mar 25, 2016 at 11:19

Your Answer

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

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