This post is about a nice little keypad I bought on Amazon. I can't remember which vendor but you can get them for 2-3$ US. I usually buy from Amazon Prime vendors if I can. Here is a photo:
They are very easy to connect up using this library. Here is a sketch that works on a MSP-EXP430F5529LP.
/*
||
|| Modified for HC-543 keypad and TI MSP-EXP430F5529LP.
|| Demonstrates changing the keypad size and key values.
||
|| Credit for original code:
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| Frank Milburn
|| 19 Feb 2015
||
|| Connections:
|| As you look at the HC-543 keypad, the first lead on the
|| left is the first row. The 5th lead over to the right
|| is the first column.
*/
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the symbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {10, 9, 8, 7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 5, 4, 3}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
Serial.println("Starting keypad...");
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey){
Serial.println(customKey);
}
}
thanks dude!
ReplyDelete