I couldn't figure out the best board to post this into. Sorry if this isn't the correct one.
I'm having trouble getting a 3x4 numeric keypad matrix wired properly to a PCF8574AN i2c I/O expander.
The keypad is the Adafruit one, not the "phone style":
Pinout is this:
So, using this pinout for reference:
And the wiring diagram here, I've wired as follows:
1 -> P5
2 -> P0
3 -> P4
4 -> P3
5 -> P6
6 -> P2
7 -> P1
(first column is pin# on keypad, 2nd # is the pin on the chip). This apparently isn't quite right. I'm using Rob Tillaart's I2CKeyPad.h library. the raw index value returned by keyPad.getKey() is:
1 = 0 (correct)
2 = 1 (correct)
3 = 2 (correct)
4 = 4 (should be 3)
5 = 5 (should be 4)
6 = 6 (should be 5)
7 = 8 (should be 6)
8 = 9 (should be 7)
9 = 10 (should be 8)
- = nothing (should be 9?)
0 = 13 (should be 10?)
= 14 (should be 11?)
The code I'm using is basically the same test code he uses, simple and straightforward:
uint8_t idx = keyPad.getKey();
if (idx != lastKey & keys[idx] != 'N') {
Serial.println(idx);
lastKey = idx;
}
I've checked my wiring several times so it is what I describe above. I must be misunderstanding something fundamental about the keypad or chip, but I'm not clear how to take the output and translate it to an answer of what is wrong and needs to be fixed.