[Solved] 4x6 Pushbuttons matrix partially unresponsive

Hi everyone.
First of all, thank you for taking the time to read my post. About a month ago I didn't know anything about circuits, arduino, coding or even pcb's, so please, bear with me if I make mistakes explaining the issue Im experiencing.

Im trying to make a macropad with keyboard switches, a 4x6 matrix connected to a Seeed Xiao RP2040. I used a Youtube video as inspiration but I did some changes based on my needs. This was just increasing the number of keys.

I managed to make it work partially. This is only 4 of the 22 keys are responsive, but even these keys are not working properly.
I will provide now schematics and details of what I managed to get done and at the end I will provide details of the issue Im experiencing.

Schematics of the circuit:

Specs of the Seeed Xiao RP2040: Getting Started with Seeed Studio XIAO RP2040 | Seeed Studio Wiki

Link to it's Datasheet : https://files.seeedstudio.com/wiki/XIAO-RP2040/res/SCHPCB.zip

Youtube video I followed for Arduino coding: https://www.youtube.com/watch?v=3iy2FWI8sWU&t=666s

Im using Arduino IDE ver 2.3.2
And these libraries:

  • Keyboard by Arduino 1.0.5
  • Simplekeypad by Maxime Bohrer 1.0.0

The code Im using:

#include <SimpleKeypad.h>
#include <Keyboard.h>
const byte nb_ROWS = 4; //four rows
const byte nb_COLS = 6; //four columns
//define the cymbols on the buttons of the keypads
char key_chars [nb_ROWS] [nb_COLS]= {
  { 0, '8', 'A', '9', 'B', 'K'},
  { 0, 'C', 'D', 'E', 'F', 'M'},
  {'0', '1', '2', '3', 'G', 'H'},
  {'4', '5', '6', '7', 'I', 'J'}
  };
byte rowPins[nb_ROWS] ={7, 8, 9, 10} ; //connect to the row pinouts of the keypad
byte colPins[nb_COLS] ={6, 5, 4, 3, 2, 1} ;

SimpleKeypad Mykeypad((char*)key_chars, rowPins, colPins, nb_ROWS, nb_COLS);

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Press any key on the keypad and it will show up here:");
}

void loop() {
  
  char key = Mykeypad.getKey();
  if (key) {
    Serial.println(key);
  }

  if (key =='K') {
    Serial.println("K Pulsada");

  }

if (key =='B') {
    Serial.println("B Pulsada");

  }

if (key =='A') {
    Serial.println("A Pulsada");

  }

if (key =='9') {
    Serial.println("9 Pulsada");

  }


}

Issue explanation: As I introduced before, only 4 out of 22 keys are responsive. The ones from Column 1 ( S1,S6,S12 and S18 ) but the problem is that when pressed, they show characters from Row 1 of the matrix in the code, this is :

S1-> K S6-> B S12-> A S18-> 9

As you can see, A and 9 are inverted, which blows my mind, honestly.
The rest of the keys do nothing when pressed.

If you have reached to this point reading, thank you.
I read the guidelines to post before I wrote all this and I hope I provided the info and explanations needed so someone can help me. If no, please let me know what else you would need and I will add it.

Im sorry for such long post, Im not capable of explaining it in a shorter manner.

Riveting.

The code looks like a good borrowing of the SimpleKeypad examples code.

What kind of switches are they, and how are you physically connecting to them?

Do you have the means to do a simple test with a jumper wire? Can you disconnect the real switches?

If you could just carefully connect on a temporary basis a certain rows pin with a certain columns pin, and try several combinations I think you will find the software is working, or learn more about why it might not be.

I do see you using two pins that are labeled somethingRX and somethingTX, I am unfamiliar with the board you are using and wonder if these are OK to use given that maybe the serial monitor and code uploading and verifying use them.

Again, if you have means, just disconnect that row and that column and see if all the other switches do what it looks like they should.

HTH

a7

Hi alto777, thanks for taking the time to look into my problem.

Yes, I took the example code because I saw that it fits very well with what I need ( I believe ).
Just some switches to launch some very simple macros, 2 and 3 key presses.

Im using keyboard switches mounted on a pcb designed specifically for the project and Im using kailh sockets ( hotswap ) as well.

Yes, I have spare switches and wires to test what you suggest, even if I have to desolder the components, that won't be a problem, I would like to solve this by all means necessary.

Ok, I will try with a 2x2 matrix first and go on from there.

Yes, as you can see in the picture attached, D6 and D7 are Rx and Tx pins, I will take a look at the datasheet about it.

I will do what you suggest, I will start testing what happens if I disconnect those two pins first and if nothing changes, I will try with a 2x2 and so.

Thanks for your help alto777, I will come back tomorrow with the results.

Well after some time looking here and there, I managed to get the solution.

Hardware was ok, so the only problem was the Arduino IDE.

I fixed this using another software to program the Seeed Xiao RP2040.

Thanks alto777 for taking the time trying to help me.