brelliott18 2 Posted December 4, 2014 Share Posted December 4, 2014 I have recently bought a LaunchPad 2553. I am a comparitive novice. I am trying to add a 4 X 4 matrix keypad. I copied some code from an Arduino source and changed #Arduino references to #Energia. I commented out a #WProgram statement - what is this ? The code compiled and verified OK . I connected the 8 wires from keypad to p1.0 -p1.7 [ and tried other ports as well ]. The output was sent to the Serial monitor via Serial.println( key ). I could only get any output by pressing many keys at the same time. I looked at the keyboard.h file but it went nothing to me. How do the DigitalReads get initiated ? [ Serial.println ("hello world " ) worked so the program does get to the right place ] Any suggestions please - pointers to existing code snippets - I can't fine any . Thanks Quote Link to post Share on other sites
abecedarian 330 Posted December 4, 2014 Share Posted December 4, 2014 Any suggestions please - pointers to existing code snippets - I can't fine any . ThanksYou didn't "search" very hard. Quote Link to post Share on other sites
brelliott18 2 Posted December 4, 2014 Author Share Posted December 4, 2014 You didn't "search" very hard. You didn't "search" very hard. So where is this information for the Msp430G2553 [ NOT the Arduino - Those didn't work ] ? Quote Link to post Share on other sites
brelliott18 2 Posted December 4, 2014 Author Share Posted December 4, 2014 This is part of the Arduino code I found for keypads [ keyboard.h ]. How should ths be altered [ if necessary ] to run on the MSP430G2553 ? Assuming I use p1.0 to p1.7 ??? for the 8 wires coming from the keypad [ 4 X 4 ] #define INPUT_PULLUP 0x2 - does this need changing ? #ifndef INPUT_PULLUP #warning "Using pinMode() INPUT_PULLUP AVR emulation" #define INPUT_PULLUP 0x2 #define pinMode(_pin, _mode) _mypinMode(_pin, _mode) #define _mypinMode(_pin, _mode) \ do { \ if(_mode == INPUT_PULLUP) \ pinMode(_pin, INPUT); \ digitalWrite(_pin, 1); \ if(_mode != INPUT_PULLUP) \ pinMode(_pin, _mode); \ }while(0) #endif #define OPEN LOW #define CLOSED HIGH typedef char KeypadEvent; typedef unsigned int uint; typedef unsigned long ulong; typedef struct { byte rows; byte columns; } KeypadSize; #define LIST_MAX 10 // Max number of keys on the active list. #define MAPSIZE 10 // MAPSIZE is the number of rows (times 16 columns) #define makeKeymap(x) ((char*)x) //class Keypad : public Key, public HAL_obj { class Keypad : public Key { public: Keypad(char *userKeymap, byte *row, byte *col, byte numRows, byte numCols); virtual void pin_mode(byte pinNum, byte mode) { pinMode(pinNum, mode); } virtual void pin_write(byte pinNum, boolean level) { digitalWrite(pinNum, level); } virtual int pin_read(byte pinNum) { return digitalRead(pinNum); } uint bitMap[MAPSIZE]; // 10 row x 16 column array of bits. Except Due which has 32 columns. Key key[list_MAX]; unsigned long holdTimer; char getKey(); bool getKeys(); KeyState getState(); void begin(char *userKeymap); bool isPressed(char keyChar); void setDebounceTime(uint); void setHoldTime(uint); void addEventListener(void (*listener)(char)); int findInList(char keyChar); int findInList(int keyCode); char waitForKey(); bool keyStateChanged(); byte numKeys(); private: unsigned long startTime; char *keymap; byte *rowPins; byte *columnPins; KeypadSize sizeKpd; uint debounceTime; uint holdTime; bool single_key; void scanKeys(); bool updateList(); void nextKeyState(byte n, boolean button); void transitionTo(byte n, KeyState nextState); void (*keypadEventListener)(char); }; #endif Quote Link to post Share on other sites
igor 163 Posted December 4, 2014 Share Posted December 4, 2014 Don't see anything obviously wrong with the INPUT_PULLUP section (since Energia defines INPUT_PULLUP the code here isn't used). Would help if you post the rest of the code (as you have modified it), or post a link to the library you are modifying (if you haven't changed it). (Please use the code attribute - the <> icon - when posting code.) Quote Link to post Share on other sites
SixSixSevenSeven 23 Posted December 4, 2014 Share Posted December 4, 2014 the arduino library is absolutely fine as is. I would attribute it to an error in your code or wiring not the library. Quote Link to post Share on other sites
brelliott18 2 Posted December 5, 2014 Author Share Posted December 5, 2014 Solved - thanks for help anyway. Thought I could use P1_1 and P1_2 but couldn't - used P1_3 upwards then P2 instead - works fine ! Quote Link to post Share on other sites
cubeberg 540 Posted December 5, 2014 Share Posted December 5, 2014 @@brelliott18 - P1_1 and P1_2 are connected to the UART -> USB bridge on the launchpad. Pulling off the TX/RX jumpers would solve that problem. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.