Keyboard matrix 4x4

Hi folks, I have a problem with keyboard connected into 4*4 matrix. I use only 14 push buttons. The problem is that all push buttons work on Arduino Mega. On Uno works only 3,4 - 5,6 - B,C. I don't understand why it doesn't work. Could someone help me? Thank you in advance.

Here is my code

#include <Keypad.h>

const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
  {'1' , '2' , '3' , '4'},
  {'5' , '6' , '7' , '8'},
  {'9' , 'A' , 'B' , 'C'},
  {'D' , 'E' , 'F' , 'G'}
  };


byte rowPins[ROWS] = {13,12,11,10};
byte colPins[COLS] = {0,1,2,3};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  char key = keypad.getKey();
  if(key != NO_KEY){
    Serial.println(key);
  }
}

I would hazard a guess that Serial.begin() and using pins 0,1 for column inputs are interfering. Try 2 other pins instead.

Thank you very much, I didn't know I can't use these pins. Problem solved :slight_smile: