Floating pin issue on a button matrix

(Using Arduino Pro Micro)
Hello, I am new to electronics and I decided to make a pcb to build my own usb controller for pc (it is not a good idea to do such a big project just arrived at electronics, I know :frowning: ). So when the pcb arrived, I assembled the pieces, I made the code to be able to detect the buttons and I realize that they make me wrong readings (Floating input). After consulting solutions, I tried to use the INPUT_PULLUP but the problem was not fixed.

So I wanted to see if I could do the following to try to fix it:
(attached pictures)

Also I attach my code (maybe the mistake is here) (Its a test code for testing the matrix, not the final code), which consists on be sending row per row a voltage and checking which column pin is LOW when I push a button.

int rowPins[] = {9,8,7,6,10};
int colPins[] = {16,14,15,18,19,20,5};
int colPin;

void setup() {

  
  for (int i = 0; i < 5; i++) {
    pinMode(rowPins[i], OUTPUT);
    digitalWrite(rowPins[i], LOW);
  }

  
  for (int i = 0; i < 7; i++) {
    pinMode(colPins[i], INPUT_PULLUP);
    digitalWrite(colPins[i], LOW);
  }
 
}

void loop() {

  colPin = 0;
  
  for (int i = 0; i < 5; i++) {
    
    digitalWrite(rowPins[i], HIGH);
    
    
    delay(250);

    for (int col = 0; col < 7; col++){

      if(digitalRead(colPins[col]) == HIGH)
      {
        colPin = 0;
      }
      else{
        colPin = colPins[col];
        break;
      }
      delay(250);
    }

    if(colPin > 0){
    Serial.print(rowPins[i]);
    Serial.print(" AND ");
    Serial.print(colPin);
    Serial.print("\n");
    }
    
    digitalWrite(rowPins[i], LOW);
   }
}

I hope I have explained well what I wanted to say :D.

Hi,
If you want to read a keypad there is a library that will help you along with many tutorials.
Try googling

arduino keypad

It will return many sources that may help.

Tom... :slight_smile:

These two lines turn the internal pullups on, then off. The result is all inputs floating.

    pinMode(colPins[i], INPUT_PULLUP);
    digitalWrite(colPins[i], LOW);

jremington:
These two lines turn the internal pullups on, then off. The result is all inputs floating.

    pinMode(colPins[i], INPUT_PULLUP);

digitalWrite(colPins[i], LOW);

Thanks for the reply. I removed these 2 lines, but it still giving me (less) floating results. So I should try to add resistors? or what can I do?

I removed these 2 lines

The first line is required. The second line was a mistake. There may be other errors -- I didn't look beyond the first one.

It is often a good idea to get your circuit and program working on a breadboard before committing to a PCB.