Need help with Bounce2

I am trying to implement debounce on a keypad. I followed the code example for multiple buttons but cannot get it to work. The digitalRead() works fine but of course with multiple instances registered for the key presses (bouncing). As you can see the from the commented code that I tried Bounce.rose() as well as Bounce.read(). It is not reading the key press so nothing prints. Any help would be appreciated.

#include <stdio.h>
#include <Bounce2.h>

//===================== Other constants =================
const char NO_KEY = ‘X’;
const char RESET = ‘R’;
const char TALK = ‘T’;
const int INTRVL = 25;

//===================== Define constants for I/O pins =============

// keypad row pins 1,2,3,4 map to arduino pins 2,3,4,5 respectivel
#define NBR_ROWPINS 4
#define NBR_COLPINS 3
const int rowPin = {2,3,4,5};

// keypad column pins 5,6,7 map to arduino pins 6,7,8 respectively
const int colPin = {6,7,8};

//Set up the keypad matrix
const char keypad[4][3] = {{‘1’,‘2’,‘3’},
{‘4’,‘5’,‘6’},
{‘7’,‘8’,‘9’},
{‘R’,‘0’,‘T’}};

Bounce *keypadDBounce = new Bounce[NBR_ROWPINS];

void setup() {

// All pins on the kepad are pulled down with 10k resisitors
// Set up the pin modes. The columns will be output and the rows will be inputs
for(int col=0; col < NBR_COLPINS; ++col) {
pinMode(colPin[col], OUTPUT);
}

// Set the row pins up for debouncing
for(int row=0; row < NBR_ROWPINS; ++row) {
//pinMode(rowPin[row], INPUT);
keypadDBounce[row].attach( rowPin[row]); //setup the bounce instance for the current button
keypadDBounce[row].interval(INTRVL); // interval in ms
}
}

void loop() {

/*

  • The keypad has 7 pins that work in a column row configuration.
  • Pins 5,6, & 7 are connected to the columns and 1 - 4 to the rows.
  • To use this effectively, set each column high, one at a time and then
  • check the pins on the rows one at a time to see if it is HIGH.
  • When the column is set high and when a row pin is read high we know which button was pressed.
  • The keypad is a 2-D matrix so let’s handle it that way.
    */
    for(int col=0; col < NBR_COLPINS; ++col) {
    digitalWrite(colPin[col], HIGH);
    for(int row=0; row < NBR_ROWPINS; ++row) {
    keypadDBounce[row].update();
    //if(digitalRead(rowPin[row]) == HIGH) {
    if(keypadDBounce[row].read() == HIGH) {
    //if(keypadDBounce[row].rose()) {
    Serial.print("Key = ");
    Serial.println(keypad[row][col]);
    }
    } // end for row
    digitalWrite(colPin[col], LOW);
    } // end for column
    }

It would help us to help you if you tell us what the problem is.

Please read the how to use this forum-please read sticky to see how to post code and some advice on how to get the most from the forum.

groundFungus:
It would help us to help you if you tell us what the problem is.

Please read the how to use this forum-please read sticky to see how to post code and some advice on how to get the most from the forum.

Oh, sorry. It's just not reading the key press so nothing prints.

And you could read the keypad working before you added Bounce2?

groundFungus:
And you could read the keypad working before you added Bounce2?

Yes, the digitalRead() works but of course has bouncing results.

Here is a keypad library that has bebounce built in. Might be easier.

groundFungus:
Here is a keypad library that has bebounce built in. Might be easier.

Thanks, I'll try it. He even has the same variables that I used, LOL.