Plain keypad How To - ska-la/kPad_i2c GitHub Wiki
Simply connect your keypad to digital pins of Arduino board.
Download and copy (look at INSTALL) the library to sketchbook/libraries/ and then use example kPad_simple.ino.
IMPORTANT!
You must edit file kPad_i2c.h before upload a sketch to Arduino board (it's easy). Why? By default the library assumes that we use a keypad through i2c interface. At the start of the file comment out a string with two straight slashes:
before:
#define _WIRE_H_
after:
//#define _WIRE_H_
That's all!
When DIY:
1.include the library to your sketch:
#include "kPad_i2c.h"
2.Define keypad's matrix size (4x4 for example)...
#define PAD_ROWS 4
#define PAD_COLS 4
...and keypad's chars table:
char symbolChart[PAD_ROWS][PAD_COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
3.Define DIGITAL pins of Arduino board, which used by keypad:
byte padPinIn[] = {2,3,4,5};
byte padPinOut[] = {6,7,8,9};
4.Create a keypad instance:
kPad kp = kPad((char *)symbolChart,padPinIn,padPinOut,(byte)PAD_ROWS,(byte)PAD_COLS);
5.more coding..
void setup() {
Serial.begin(115200);
kp.init();
}
void loop() {
char smbl = kp.read();
if (smbl) {
Serial.write(smbl);
}
}
6.check the sketch and upload into a Arduino board. FINISH.