The following shows an example using the Adafruit Keypad Arduino library.
Install Keypad Library
You can install the Keypad library via the Library Manager.
Tools -> Manage Libraries...
Open it, search for 'keypad', and click Install on the one labeled Adafruit Keypad.
Example
For this example we will use the 3x4 Matrix Keypad (PID3845). Here is the wiring.
In the Arduino IDE open the example:
File -> Examples -> Adafruit Keypad -> keypad_test
Find these lines of code up near the top:
// define your specific keypad here via PID #define KEYPAD_PID3844
and change it to this to match the keypad being used:
// define your specific keypad here via PID #define KEYPAD_PID3845
Upload the sketch and then open the Serial Monitor
Tools -> Serial Monitor
Try pressing the buttons. You should see text like this:
Note that each press produces two messages. One for the down (pressed) and one for the up (released).
Text editor powered by tinymce.