Hi All,
I have an 8 x 8 button matrix that works fine when a single button is pressed. It also works fine when about 15 buttons are pressed and held. However after that amount, it starts to become unstable and I get button triggers from adjacent rows on the same column.
I have a diode on every button and a diode on every row.
Each row and column is connected to a pin on the teensy. I have input pullup set on each column. The length of cable is around 6 meters but might endup being longer.
Below is my scan routine:
<
void FigTree_Keypad::scanKeys() {
int delayTime = 100;
for (byte r=0; r<sizeKpd.columns; r++) {
pin_mode(columnPins[r],INPUT_PULLUP);
}
// enable row (set to LOW)
for (byte r = 0; r < sizeKpd.rows; r++) {
pin_mode(rowPins[r], OUTPUT);
pin_write(rowPins[r], LOW); // Pull the current row pin LOW
delayMicroseconds(delayTime);
for (byte c = 0; c < sizeKpd.columns; c++) {
//pin_mode(columnPins[c], INPUT_PULLUP); // Temporarily set column pins to input with pull-up
bitWrite(bitMap[r], c, !pin_read(columnPins[c])); //keypress is active low
}
pin_write(rowPins[r], HIGH);
pin_mode(rowPins[r], INPUT_PULLUP);
}
}>
Any suggestions for circuit/code improvement would be greatly appreciated.
I have an 8 x 8 button matrix that works fine when a single button is pressed. It also works fine when about 15 buttons are pressed and held. However after that amount, it starts to become unstable and I get button triggers from adjacent rows on the same column.
I have a diode on every button and a diode on every row.
Each row and column is connected to a pin on the teensy. I have input pullup set on each column. The length of cable is around 6 meters but might endup being longer.
Below is my scan routine:
<
void FigTree_Keypad::scanKeys() {
int delayTime = 100;
for (byte r=0; r<sizeKpd.columns; r++) {
pin_mode(columnPins[r],INPUT_PULLUP);
}
// enable row (set to LOW)
for (byte r = 0; r < sizeKpd.rows; r++) {
pin_mode(rowPins[r], OUTPUT);
pin_write(rowPins[r], LOW); // Pull the current row pin LOW
delayMicroseconds(delayTime);
for (byte c = 0; c < sizeKpd.columns; c++) {
//pin_mode(columnPins[c], INPUT_PULLUP); // Temporarily set column pins to input with pull-up
bitWrite(bitMap[r], c, !pin_read(columnPins[c])); //keypress is active low
}
pin_write(rowPins[r], HIGH);
pin_mode(rowPins[r], INPUT_PULLUP);
}
}>
Any suggestions for circuit/code improvement would be greatly appreciated.