Fingerprint, LCD, SD

Hello!

My project is a fingerprint sensor with I2C LCD. It's working well. I have to log data with an SD card module. I found a code on web and it's working (sensor+lcd). Now I have to insert the code of SD but I don't know how. Please help.. I want to use this code because it's the best. I just want to modify it. Thanks! :confused:

int green = 9; 
int red = 8; 
int open = 0;
int close = 1;
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 
int angulo = 179; 

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(2, 3);


Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()  
{
  Serial.begin(9600);
 lcd.begin(16,2); 
  pinMode(green, OUTPUT);
  pinMode(red, OUTPUT);
  Serial.println("fingertest");

  finger.begin(57600);
  
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
  digitalWrite(green, LOW);
  digitalWrite(red, HIGH);
  lcd.setCursor(0, 0);
        lcd.print("SMART DOOR ");
        lcd.setCursor(0, 1);
        lcd.print("PLEASE WAIT..");
 delay(3000);
 Serial.println("DOOR IS OPEN");
 LimpiaFila1();
 DoorClosed();
 

}

void loop()                     // run over and over again
{
  getFingerprintIDez();
  delay(50);            //don't ned to run this at full speed.
}

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

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
  
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
  
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID); 
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

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

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
  
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID); 
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  if (finger.fingerID == 1){
  
 
  switch (open){
     case 0:
  Open(); 
  finger.fingerID=0;  
  LimpiaFila1();
  DoorOpen();
  digitalWrite(green, HIGH);
  digitalWrite(red, LOW);
  delay(3000);
  break;
  case 1:
  Close(); 
  finger.fingerID=0;  
  LimpiaFila1();
  DoorClosed();
  digitalWrite(green, LOW);
  delay(1000);
  digitalWrite(red, HIGH);
  break;
  }
  }
  else if (finger.fingerID != 1){
  Serial.println("UNAUTHORIZED PERSON");
  LimpiaFila0();
  NoAccess();
  digitalWrite(red, HIGH);
  delay(3000);
  digitalWrite(red, LOW);
  LimpiaFila0(); 
  lcd.setCursor(0, 0);
  lcd.print("SMART DOOR ");  
  }
  return finger.fingerID; 
}

void LimpiaFila0()
{
 for(int i = 0; i < 16; i++){
  lcd.setCursor(i, 0);
  lcd.print(" ");
  }
}

void LimpiaFila1()
{
 for(int i = 0; i < 16; i++){
  lcd.setCursor(i, 1);
  lcd.print(" ");
  }
}

void LimpiaDisplay()
{
 for(int i = 0; i < 16; i++){
  lcd.setCursor(i, 0);
  lcd.print(" ");
        lcd.setCursor(i, 1);
  lcd.print(" ");
  }
}

void DoorOpen()
{
  lcd.setCursor(0, 1);
  lcd.print("DOOR IS OPEN");
}

void DoorClosed()
{
  lcd.setCursor(0, 1);
  lcd.print("DOOR IS CLOSED");
}
void NoAccess()
{
  lcd.setCursor(0, 0);
  lcd.print("ACCESS DENIED");
}

void Wait()
{
  lcd.setCursor(0, 1);
  lcd.print("PLEASE WAIT");
}

void Open()
{
  angulo = 90;
  delay(15);   
  open = 1;
  close = 0;
}
void Close()
{
  angulo = 179;
  delay(15);   
  open = 0;
  close = 1;
}

Fingerprint sensor: Fingerprint sensor : ID 751 : $49.95 : Adafruit Industries, Unique & fun DIY electronics and kits
LCD: http://i.ebayimg.com/00/s/MTA2NlgxNjAw/z/T6kAAOSwv0tVHRy4/$_57.JPG
SD module: https://cdn.instructables.com/F6V/F1OJ/H5ENQ08B/F6VF1OJH5ENQ08B.MEDIUM.jpg

This is the third thread by you on pretty much the same topic.
Any good reason for this?

OK, step 1 is to make sure you understand the code you have and how it works.

Step 2 is to find code that does SD logging and try to understand how it works.

Once you understand how both of those work, putting it together will be simple. You'll need to add some stuff to setup to set up the SD card and get it ready and you'll need to add lines somewhere (probably close to where you are displaying the data) to write that data to the SD card.