I2C keypad How To - ska-la/kPad_i2c GitHub Wiki
HARDWARE DETAILS.
What we have on a board? On the schematic diagram (Pic 1) it's included into a purple rectangle. It's no exactly same what we have, but main features are present here. Pins 9(En), 10(R/W), 11(Rs) and 12 (PCF8574 chip) are connected to keypad's inputs (look at plain keypad explanation). Pins 4-7 (D4-D7) are connected to a keypad's outputs and pulled up (to +5V) with 1 kOhm resistors (4 pieces) each.
Pic 1
Pins 4-7 of PCF8574 correspond to a LCD I2C interface board's pins into a green rectangle (Pic 2). And pins 9-12 correspond to pins into a domain with red border. Red and green rectangles on Pic 2 are corresponding to the same colors rectangles on Pic 1.
Pic 2
CAUTION!
- Don't remove a cap into a purple oval (Pic 2). It's responsible for the signal on board's pin 16 is correct.
- Don't forget to change i2c address the board if you have device (like LCD) with the same I2C/TWI adapter. Simply solder together one of the address pairs (A0-A2 into a domain of I2C address selector Pic 2).
SOFTWARE DETAILS.
File kPad_i2c.h has such definition:
#define BOARD_MASK 0xF7
Why? Look at pictures 3 and 4. Colors green, emerald and yellow denote the same things on both pictures: transistor, two-pin connector with a cap and 16th pin of the I2C interface board. 16th pin of the board provides a signal from a point into a yellow ring that's between transistor T1 and resistor R1. As result, we have an inverted signal value of 12th pin of PCF8574 chip on 16th board's pin.
Board's pins 4,5,6 and 16 form a low nibble of a control byte which we use to select a keypad row. And pins 11,12,13 and 14 form a high nibble which we use to detect which key is pressed. If you will use an own realization of i2c (on bare "remote I/O extender" like PCF8574) for a keypad without a I2C interface adapter, you must change BOARD_MASK definition:
#define BOARD_MASK 0xFF
Test an included example kPad_i2c.ino .