#include <Keypad.h>

// Define Keypad Rows and Columns
const byte ROWS = 4;
const byte COLS = 4;

// This should match your actual keypad layout
char keys[ROWS][COLS] = {
  { '1', '2', '3', 'A' },
  { '4', '5', '6', 'B' },
  { '7', '8', '9', 'C' },
  { '*', '0', '#', 'D' }
};

// Change these to match your actual ESP32 GPIO connections
byte colPins[COLS] = {21, 4, 3, 2};  // GPIOs connected to keypad columns
byte rowPins[ROWS] = {20, 8, 9, 10};  // GPIOs connected to keypad rows
Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); 

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
  }
}
esp:D0
esp:D1
esp:D2
esp:D3
esp:D4
esp:D5
esp:D6
esp:D7
esp:D8
esp:D9
esp:D10
esp:3V3
esp:GND
esp:5V
keypad1:R1
keypad1:R2
keypad1:R3
keypad1:R4
keypad1:C1
keypad1:C2
keypad1:C3
keypad1:C4