8 x 8 button matrix help

damo1976

Well-known member
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.
 
You may want to share your complete code (including a reference to the used libraries) in case someone has the same hardware available and would like to try.
Please use the </> button in the top-left corner of this window if you want to share your code - much more readable.
C++:
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);
  }
}

Did you perhaps try the Teensyduino included Keypad library? Useful examples are also included.

The length of cable is around 6 meters but might endup being longer.
This triggered me as well. Six meters (~20 feet) is pretty long - you could see all kind of weird effects. Did you try to get it to work with less than 1 foot of wiring?

Paul
 
I've slowed the scan down and going to try adding caps and 4.7k pullups. Hopefully that will help,

I based my scan library on the keypad library.
 
Back
Top