How can I set the data obtained with a keypad?

Hi, I’m trying to set the data in a NOKIA5110 Display or Adafruit_PCD8544, I’m using a simple 4x4 keypad and an Arduino UNO.

The problem is that I can’t set the data in the display. The value of the keypad is giving by an resistors array through analogical pin A0.

Here is a scheme of the array and the code.

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

int thresholds[16]={1,78,145,203,246,292,333,369,396,426,454,479,498,520,540,558};
char keypad[16]={'A','3','2','1','B','6','5','4','C','9','8','7','D','#','0','*'};


// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7,6,5,4,3);


void setup() {
  Serial.begin(9600);
    
  display.begin();
  display.setContrast(50);
  display.display();
  delay(500);
  display.clearDisplay();
  // text display tests
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(0,5);//col,row
  display.println("   PASSWORD   ");//14CHAR
  display.println("______________");
  display.display();
//  display.clearDisplay();
}

void loop() {
  int value = analogRead(A0);

  for(int i=0; i<16; i++){
    if(abs (value-thresholds[i])<7){//If A0 is close enough to one of the keypad values?
      display.setTextSize(1);
      display.setTextColor(BLACK);
      display.setCursor(7,10);//col,row
      display.print(keypad[i]);//Translate the index of that value to the actual name of the key
      while(analogRead(A0)<1000){//Wait until they release the button
        delay(100);
      }
    }
  }
}

Keypad with 16 keys.gif