KEYPAD coding problem

Hello, I am new to arduino and writing code. I am trying to do a code that will convert decimal number enter by a user using a keypad and it will display on serial monitor. Im working on a project to create a time based password using an algorithm.

The problem I have is my serial monitor wont print number 4,5,6,B. I cant seem to find a problem with my code. Can someone guide me please?

I am using 4x4 keypad and my keypad is working fine as I tried to test it using my other code on other project and it works perfectly.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Password.h>
#include <Keypad.h>

LiquidCrystal_I2C lcd(0x3F, 16, 2);

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns

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

byte rowPins[ROWS] = { 0, 1, 2, 3 };
byte colPins[COLS] = { 4, 5, 6, 7 };

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
  Serial.print("Decimal : ");
}


void loop()
{
  char key = kpd.getKey(); //storing pressed key value in a char
  if (key != NO_KEY)
{
      switch(key){
        
        default : processNumberKey(key);
      }
  }
}

void processNumberKey(char key)
  {
    Serial.print(key);
  }

Which Arduino?

Pete

It is not recommended to use D0 or D1 as these are serial RX and TX.

Use other pins.

.

LarryD:
It is not recommended to use D0 or D1 as these are serial RX and TX.

Use other pins.

.

I am using arduino uno.
I used other pin than D0 and D1 and it works. Thank you :slight_smile: