Teensy Keypad Matrix Reading Strange Ports?

Status
Not open for further replies.

mickeyfergey

New member
So I have a custom project that I'm working on, and essentially the whole thing is a 12x8 keypad. For ergonomic and personal reasons, I wanted it to be not just a perfect grid, but have spacing inbetween some rows and columns. But it can be simplified down to just a 12x8 keypad. I'm currently using Teensyduino to code my Teensy 4.1 with the Keypad.h library, and the code is loading just fine with no errors to the Teensy. The code is very basic. But the Teensy is reading strange ports. rowPin 1 and colPin 9 correspond to an output of 1 just fine. And I assumed that rowPin 1 and colPin 10 would correspond to an output of 2. But it doesn't. On the Serial Monitor, there is no output. But if I increase the rowPin, with colPin still on 9, rowPin 1 outputs 1, rowPin 2 outputs 7, rowPin 3 outputs 13, rowPin 4 outputs 19, rowPin 5 outputs 25, etc. All increasing by 6. But if I look at the array, these outputs are not coming from where they should. What am I doing wrong?

(This is my first time posting here so if I'm doing something wrong or should edit my post, please kindly let me know. Thanks!)


#include <Keypad.h>

const byte ROWS = 8;
const byte COLS = 12;

int hexaKeys[ROWS][COLS] = {

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},

{13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
{25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36},

{37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48},
{49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60},
{61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72},
{73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84},
{85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96}


};

byte rowPins [ROWS] = {1, 2, 3, 4, 5, 6, 7, 8};
byte colPins [COLS] = {9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};

//Create keypad object

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
Serial.begin(9600);
}

void loop() {
int customKey = customKeypad.getKey();

if (customKey) {
Serial.println(customKey);
}
}
 
Status
Not open for further replies.
Back
Top