Arduino giga & keypad

Hi,

I need some help, I'm trying to use a 4x4 keypad, but something strange happens.
Here is my code

#include <Keypad.h>

#define ROWS 4
#define COLS 4

const char kp4x4Keys[ROWS][COLS] 	= {{'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'}};
byte rowKp4x4Pin [4] = {9, 8, 7, 6};
byte colKp4x4Pin [4] = {5, 4, 3, 2};

Keypad kp4x4 	= Keypad(makeKeymap(kp4x4Keys), rowKp4x4Pin, colKp4x4Pin, ROWS, COLS);

void setup() {
 	Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
 	Serial.print("Initialize System");
}
void loop() {
 	readKp4x4();
}

void readKp4x4() { 

 	char customKey = kp4x4.getKey();
 	if (customKey) {
 			Serial.println(customKey);
 	}
}

When I connect pin 9, 8, 7 or 6, I got in the serial monitor, an infinite loop which print respectively 1, 4, 7 or *, depending the pin I connected.
What's wrong with my code ?
Thanks for your help.

Welcome to the forum

Is the Keypad library compatible with the Giga ?

Thank you.
That is a good question, I really don't know.
That should be the reason why...because with an Arduino uno it works.

may be we could move this question into the Giga category where it might get eyeballs familiar with the board?

I just checked and it seems the library depends just on pinMode and digitalRead / digitalWrite

nothing fancy - so should work (as long as the pin can be set to OUTPUT, INPUT_PULLUP or INPUT)

nothing wrong. it works as programed.

147* is first column

#include <Keypad.h>

#define ROWS 4
#define COLS 4

const char kp4x4Keys[ROWS][COLS]   = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
const byte rowKp4x4Pin [4] = {9, 8, 7, 6};
const byte colKp4x4Pin [4] = {5, 4, 3, 2};

Keypad kp4x4(makeKeymap(kp4x4Keys), rowKp4x4Pin, colKp4x4Pin, ROWS, COLS);

void setup() {
  Serial.begin(115200);
  Serial.print("Initialize System");
}

void loop() {
  char customKey = kp4x4.getKey();
  if (customKey)     Serial.println(customKey);  
}

So, it should work without changing/doing something ?

I think so, I thought there was maybe something to change to be compatible.

well the test could be clearer

  if (customKey != NO_KEY) Serial.println(customKey);  

but this should not be the issue

may be try to use other pins than 8 and 9 which are I2C pins

show your setup

I changed the line as you mentionned but as you told I still got the issue.
I tried pin 31 instead of the 9, but it's the same.

It is always difficult to know whether to move queries such as this to board specific categories

Moving it to the Giga category may get more specialist attention but here in the Programming category it will get more views I suspect

try moving BOTH (8 and 9) somewhere else

i would check this keypad if it work proper with DMM.
and such problem i would examine on breadboard without keypad, but with one simple wire or tactile buttons.

Try this change to Keypad.h

//#ifndef INPUT_PULLUP
#if ! (defined(INPUT_PULLUP) || (ARDUINO_API_VERSION >= 10000))

In cores based on the ArduinoCore-API pin modes are defined as enums instead of macros.
Furthermore, I don't think the Giga core emulates AVR's INPUT+HIGH = PULLUP.

1 Like

You're right !
After adding that line, it works !
Thank you so much.

good catch - might be worth posting an issue or pull request in the libraries' GitHub

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.