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.
Serial.println("Hello World");
afterSerial.begin(9600);
just to make sure it's not unrelated to your code. \$\endgroup\$if (key != NO_KEY)
rather thanif(key)
\$\endgroup\$