Punch in your secret key into this numeric matrix keypad. This keypad has 16 buttons, arranged in a telephone-line 4x4 grid. It's made of a thin, flexible membrane material with an adhesive backing (just remove the paper) so you can attach it to nearly anything.
This keypad has 8 wires running from the bottom of the keypad, the wires connect in sequence from left to right and hook up to Arduino digital pin 2-9. You can get the Library from Arduino IDE, The following code below will allow you to test the keypad as each key is pressed, the corresponding character should appear on a separate line in IDE serial console.
Technical Details
Arduino codes:
=============================================================================
#include // You need to include this library from your IDE
constbyteROWS=4;
constbyteCOLS=4;
charkeys[ROWS][COLS]={
{'1','2','3','A'},// Row 1
{'4','5','6','B'},// Row 2
{'7','8','9','C'},// Row 3
{'*','0','#','D'} // Row 4
};
byterowPins[ROWS]={2,3,4,5};// Connect to Pin Row
pinouts
bytecolPins[COLS]={6,7,8,9};//connect to Pin Column
pinouts
Keypad keypad=Keypad(makeKeymap(keys),rowPins,
colPins,ROWS,COLS);
voidsetup(){
Serial.begin(9600);// Serial Console
}
voidloop(){
charkey=keypad.getKey();
if(key!=NO_KEY){
Serial.println(key);// Display to Serial Console
}
}
=============================================================================
Tutorial:
1. Matrix Keypad Arduino Library