merge codes it returned no error but wouldnt work with my project

hi. i have a keypad and lcd code and tried to merge it with my fingerprint and enroll codes i tried tu run it and it returned no error but when i upload it to my project it doesnt work. currently i have to use the serial monitor to display the output and input. i want to use my 4×4 Matrix Keypad for input and 16X2 lcd for display output.

both of the above codes that i merged

            #include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <Keypad.h>
#include <Wire.h> // for I2C LCD
#include <LiquidCrystal_I2C.h>


int getFingerprintIDez();
uint8_t getFingerprintEnroll(uint8_t id);



SoftwareSerial mySerial(2, 3);
LiquidCrystal_I2C lcd(0x27, 16, 2);


const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] =
 {{'1','4','*','7'},
  {'2','5','0','8'},
  {'3','6','#','9'},
  {'A','B','D','C'}};
byte rowPins[ROWS] = {
  7, 6, 5, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  11, 10, 9, 8}; //connect to the column pinouts of the keypad
int count=0;
 
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()  
{
  Serial.begin(9600);
   lcd.begin();
  //pinMode(button, INPUT); 

  // set the data rate for the sensor lcd port
  finger.begin(57600);
  
  if (finger.verifyPassword()) {
    lcd.println("Found fingerprint sensor!");
  delay(50);
  } else {
    lcd.println("Did not find fingerprint sensor :(");
    while (1);
    
  }
  
}

void loop()                     // run over and over again
{
    
  lcd.println("For Enrolling Press 1, For Searching Press 2");
  delay(50);
   char key= keypad.getKey();
  while (true) {
    while (! Serial.available());
    char k = Serial.read();
    if (! isdigit(k)) break;
     
    key = k - '0';
  }

  if(key == 'A')
  {
lcd.println("Type in the ID # you want to save this finger as...");
  uint8_t id = 0;
  while (true) {
    while (! Serial.available());
    char c = Serial.read();
    if (! isdigit(c)) break;
    id *= 10;
    id += c - '0';}
    lcd.println("Enrolling ID #");
  lcd.println(id);
  
  while (!  getFingerprintEnroll(id) );
  
  }
  

   if(key == 'B')
{
  lcd.println("Waiting for valid finger...");
  int ret;
  do {
    ret = getFingerprintIDez();
    delay(50);
  } while (ret < 0);

}

  
//don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
  uint8_t n = finger.getImage();
  switch (n) {
    case FINGERPRINT_OK:
    
      lcd.println("Image taken");
      
      break;
    case FINGERPRINT_NOFINGER:
      lcd.println("No finger detected");
      return n;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.println("Communication error");
      return n;
    case FINGERPRINT_IMAGEFAIL:
      lcd.println("Imaging error");
      return n;
    default:
      lcd.println("Unknown error");
      return n;
  }

  // OK success!

  n = finger.image2Tz();
  switch (n) {
    case FINGERPRINT_OK:
      lcd.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      lcd.println("Image too messy");
      return n;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.println("Communication error");
      return n;
    case FINGERPRINT_FEATUREFAIL:
      lcd.println("Could not find fingerprint features");
      return n;
    case FINGERPRINT_INVALIDIMAGE:
      lcd.println("Could not find fingerprint features");
      return n;
    default:
      lcd.println("Unknown error");
      return n;
  }
  
  // OK converted!
  n = finger.fingerFastSearch();
  if (n == FINGERPRINT_OK) {
   
    lcd.println("Found a print match!");
    
  } else if (n == FINGERPRINT_PACKETRECIEVEERR) {
    lcd.println("Communication error");
    return n;
  } else if (n == FINGERPRINT_NOTFOUND) {
    

    lcd.println("Did not find a match");
    return n;
  } else {
    lcd.println("Unknown error");
    return n;
  }   
  
  // found a match!
  lcd.print("Found ID #"); lcd.print(finger.fingerID); 
  lcd.print(" with confidence of "); lcd.print(finger.confidence); 
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {

  uint8_t n = finger.getImage();
  if (n != FINGERPRINT_OK)  return -1;

  n = finger.image2Tz();
  if (n != FINGERPRINT_OK)  return -1;

  n = finger.fingerFastSearch();
  if (n != FINGERPRINT_OK)  return -1;
  
  // found a match!
  lcd.print("Found ID #"); lcd.print(finger.fingerID); 
  lcd.print(" with confidence of "); lcd.println(finger.confidence);
  return finger.fingerID; 
  
  
}

uint8_t getFingerprintEnroll(uint8_t id) {
uint8_t p = -1;

  lcd.println("Waiting for valid finger to enroll");
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      lcd.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      lcd.println(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      lcd.println("Imaging error");
      break;
    default:
      lcd.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
    case FINGERPRINT_OK:
      lcd.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      lcd.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      lcd.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      lcd.println("Could not find fingerprint features");
      return p;
    default:
      lcd.println("Unknown error");
      return p;
  }
  
  lcd.println("Remove finger");
  delay(2000);
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }

  p = -1;
  
  lcd.println("Place same finger again");
  delay(500);
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      lcd.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      lcd.print(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      lcd.println("Imaging error");
      break;
    default:
      lcd.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
    case FINGERPRINT_OK:
    
      lcd.println("Image converted");
      delay(1000);
      break;
    case FINGERPRINT_IMAGEMESS:
      lcd.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      lcd.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      lcd.println("Could not find fingerprint features");
      return p;
    default:
      lcd.println("Unknown error");
      return p;
  }
  
  
  // OK converted!
  p = finger.createModel();
  if (p == FINGERPRINT_OK) {
    
    lcd.println("Prints matched!");
    delay(1000);
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    lcd.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_ENROLLMISMATCH) {
    lcd.println("Fingerprints did not match");
    return p;
  } else {
    lcd.println("Unknown error");
    return p;
  }   
  
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    
    lcd.println("Stored!");
    delay(500);
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    lcd.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    lcd.println("Could not store in that location");
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    lcd.println("Error writing to flash");
    return p;
  } else {
    lcd.println("Unknown error");
    return p;
  }   
}

and i have attached the keypad&lcd code and fingerprint&enroll code (combined codes)

thank you

KEYPAD___LCD_FYP.ino (1.09 KB)

COMBINED_CODES.ino (6.94 KB)

You have some serial output that you want to share?

sorry i pasted the wrong codes just now. this one is the one that i have merged.

I really
do not understand
why your code
wanders all over
the page like
it was typed by
a drunken monkey.

Use Tools + Auto Format to sober up the monkey.

The code does something. You have not explained what is actually does. You expect it to do something, but you have not explained what you expect it to do.

It's hard to help you get from point A (non-working code) to point B (working code) without knowing where points A and B are, and which way you are facing.

ok my bad im new with this programming thing.

i have attached a picture of the output on the serial monitor. my project uses a LCD display and a matrix 4x4 keypad want to be able to use the keypad to input 1 or 2 and for the lcd to display what currently the serial monitor is displaying.

i have attached a picture of the

text. Well, I do not intend to look at a picture of text.

my project uses a adafruit fingerprint scanner, keypad and LCD. when i run the codes it asks the user to either enter 1 for enrolling process or 2 for searching enrolled fingerprints.

the codes when uploaded now displays the output on the serial monitor and i have to use my computer keyboard to input 1 or 2. what i want it to do is when i upload it will display on the 16X2 LCD and use my matrix keypad to input 1 or 2.

i hope my explanation is clear.

lcd.println("Found fingerprint sensor!");

Your code is filled with this lcd.println() syntax. It is not valid. You need to position the cursor where you want to start printing with lcd.setCursor(column,row). Then use lcd.print().

Do you have the correct constructor for your i2c lcd display?

 LiquidCrystal_I2C lcd(0x27, 16, 2);

Can you run a library example.