Fingerprint with TFT 1.4"

hello freinds .
i would like to share my idea with you guys ,
i did my project is garage door opener with blynk for sure .and i thought it would be more cool to be able to open and close the door with fingerprint sensor and also u can add member of the family too.
am using arduino nano and TFT 1.4" and for the garage opener am usuing photon ,i know i can use photon to do it both together but i wanted to do it with nano i havnt test the TFT with photon yet thats y .

this is the code am using LED for test now then ill hook it up to my project
thank you Blynk for this amazing App u offering for us and make every thing easy for us as well.
happy new year



    #include <SPI.h>
    #include <Adafruit_GFX.h>
    #include <TFT_ILI9163C.h>
    #include <Adafruit_Fingerprint.h>
    #include <SoftwareSerial.h>

    // Color definitions
    #define BLACK   0x0000
    #define BLUE    0x001F
    #define RED     0xF800
    #define GREEN   0x07E0
    #define CYAN    0x07FF
    #define MAGENTA 0xF81F
    #define YELLOW  0xFFE0  
    #define WHITE   0xFFFF

    #define relay 5
    #define __CS 10
    #define __DC 9
    static const uint8_t icon [] PROGMEM = {
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
    0x0,0x0,0x0,0x3f,0xc0,0x0,0x0,0x0,
    0x0,0x0,0x3,0xff,0xf8,0x0,0x0,0x0,
    0x0,0x0,0x7,0xff,0xfe,0x0,0x0,0x0,
    0x0,0x0,0x1f,0xc0,0x7f,0x80,0x0,0x0,
    0x0,0x0,0x3e,0x0,0x7,0xc0,0x0,0x0,
    0x0,0x0,0x7c,0x0,0x3,0xe0,0x0,0x0,
    0x0,0x0,0xfd,0xff,0x81,0xf0,0x0,0x0,
    0x0,0x0,0xff,0xff,0xe0,0xf0,0x0,0x0,
    0x0,0x1,0xff,0xff,0xf8,0x78,0x0,0x0,
    0x0,0x1,0xff,0x80,0x7c,0x38,0x0,0x0,
    0x0,0x3,0xfc,0x0,0xe,0x3c,0x0,0x0,
    0x0,0x3,0xf0,0x0,0x7,0x1c,0x0,0x0,
    0x0,0x7,0xc0,0x7f,0x83,0x8e,0x0,0x0,
    0x0,0x7,0x83,0xff,0xe0,0xe,0x0,0x0,
    0x0,0x7,0xf,0xff,0xf8,0xf,0x0,0x0,
    0x0,0x6,0x1f,0x80,0xfc,0x7,0x0,0x0,
    0x0,0x4,0x7e,0x0,0x3f,0x7,0x0,0x0,
    0x0,0x0,0xf8,0x0,0xf,0x7,0x0,0x0,
    0x0,0x0,0xf0,0x3e,0x7,0x87,0x0,0x0,
    0x0,0x1,0xe1,0xff,0x83,0x83,0x80,0x0,
    0x0,0x3,0xc3,0xff,0xc3,0xc3,0x80,0x0,
    0x0,0x3,0xc7,0xc3,0xe1,0xc3,0x80,0x0,
    0x0,0x3,0x8f,0x0,0xf1,0xe3,0x80,0x0,
    0x0,0x7,0x1e,0x0,0x78,0xe3,0x80,0x0,
    0x0,0x7,0x1e,0x3c,0x38,0xe3,0x80,0x0,
    0x0,0x7,0x1c,0x7e,0x38,0xe3,0x80,0x0,
    0x0,0xf,0x1c,0x7f,0x38,0xe3,0x80,0x0,
    0x0,0xe,0x3c,0xf7,0x38,0x71,0x80,0x0,
    0x0,0xe,0x38,0xe7,0x38,0x71,0xc0,0x0,
    0x0,0xe,0x38,0xe7,0x38,0x71,0xc0,0x0,
    0x0,0xe,0x38,0xe7,0x38,0x73,0xc0,0x0,
    0x0,0xe,0x38,0xe3,0x98,0xe3,0xc0,0x0,
    0x0,0xe,0x38,0xe3,0xb8,0xe3,0x80,0x0,
    0x0,0x0,0x38,0xe3,0xf8,0xe3,0x80,0x0,
    0x0,0x0,0x38,0xe3,0xf8,0xe3,0x80,0x0,
    0x0,0x0,0x3c,0xf1,0xf1,0xe3,0x80,0x0,
    0x0,0x6,0x1c,0x70,0x1,0xc7,0x80,0x0,
    0x0,0xe,0x1c,0x78,0x3,0xc7,0x80,0x0,
    0x0,0xf,0x1c,0x3e,0x7,0x87,0x0,0x0,
    0x0,0xf,0x1e,0x3f,0xff,0x8f,0x0,0x0,
    0x0,0xf,0x1e,0x1f,0xff,0x1f,0x0,0x0,
    0x0,0xf,0xf,0x7,0xfc,0x3e,0x0,0x0,
    0x0,0x7,0x87,0x80,0x0,0x7c,0x0,0x0,
    0x0,0x7,0x87,0xe0,0x0,0xfc,0x0,0x0,
    0x0,0x3,0xc3,0xf8,0x7,0xf8,0x0,0x0,
    0x0,0x3,0xe1,0xff,0xff,0xe1,0x0,0x0,
    0x0,0x1,0xe0,0x7f,0xff,0x83,0x0,0x0,
    0x0,0x1,0xf8,0xf,0xfe,0x7,0x0,0x0,
    0x0,0x0,0xfc,0x0,0x0,0xe,0x0,0x0,
    0x0,0x0,0x3f,0x0,0x0,0x3c,0x0,0x0,
    0x0,0x0,0x1f,0xe0,0x1,0xf8,0x0,0x0,
    0x0,0x0,0x7,0xff,0xff,0xf0,0x0,0x0,
    0x0,0x0,0x1,0xff,0xff,0xc0,0x0,0x0,
    0x0,0x0,0x0,0x1f,0xfc,0x0,0x0,0x0,
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
    0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
    };


    TFT_ILI9163C display = TFT_ILI9163C(__CS,8, __DC);
    SoftwareSerial mySerial(2, 3);
    Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
    int fingerprintID = 0;

    void setup(void) {

      startFingerprintSensor();
      display.begin();
      displayLockScreen(); 
      pinMode(relay,OUTPUT);
    }

    void loop() {

      fingerprintID = getFingerprintID();
      delay(50);
      if(fingerprintID == 1) //Dan
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayDan();
       garageDoorOpen();
       delay(2000);
        display.fillScreen(BLACK);
        displayLockScreen();
        garageDoorClose();
      }

       if(fingerprintID == 2)  //ophie
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayOphie();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
       if(fingerprintID == 3) //bakos
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayBakos();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
       if(fingerprintID == 4)  //Ann
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayAnn();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
       if(fingerprintID == 5) //nabila
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayNabila();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
       if(fingerprintID == 6) //homi
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayHomi();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
       if(fingerprintID == 7) //Allen
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayAllen();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
       if(fingerprintID == 8) //nevin
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayNevin();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
      if(fingerprintID == 9) //nevin
      {
        display.drawBitmap(30,35,icon,60,60,GREEN);
        delay(2000);
        displayUnlockedScreen();
        displayAshuram();
        garageDoorOpen();
        delay(2000);
        garageDoorClose();
        display.fillScreen(BLACK);
        displayLockScreen();
      }
    }


    void displayUnlockedScreen()
    {
       display.fillScreen(BLACK);
       display.drawRect(0,0,128,128,WHITE);
       
       display.setCursor(18,10);
       display.setTextColor(GREEN); 
       display.setTextSize(2);
       display.print("UNLOCKED");

       display.setCursor(20,50);
       display.setTextColor(WHITE); 
       display.setTextSize(2);
       display.print("WELCOME");
    }
    void displayOphie()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Ophie!");
    }
    void displayBakos()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Bakos!");
    }
    void displayNabila()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Nabila!");
    }

    void displayDan()
    {
      display.setCursor(25,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Dan!");
    }
    void displayAnn()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Ann!");
    }
    void displayAllen()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Allen!");
    }
    void displayHomi()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Homi!");
    }
    void displayNevin()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Nevin!");
    }
    void displayAshuram()
    {
      display.setCursor(35,75);
      display.setTextColor(WHITE); 
      display.setTextSize(2);
      display.print("Ashuram!");
    }

    void displayLockScreen()
    {
      display.drawRect(0,0,128,128,BLUE);
      display.setCursor(30,10);
      display.setTextColor(RED); 
      display.setTextSize(2);
      display.print("LOCKED");

      display.setCursor(10,100);
      display.setTextColor(RED); 
      display.setTextSize(1);
      display.print("Waiting for valid \n    fingerprint.");

      display.drawBitmap(30,35,icon,60,60,WHITE);
    }
    void garageDoorOpen()
    {
      digitalWrite(relay,HIGH);
      
    }
    void garageDoorClose()
    {
      digitalWrite(relay,LOW);
    }
    void startFingerprintSensor()
    {
      Serial.begin(9600);
      finger.begin(57600);
      
      if (finger.verifyPassword()) {
        Serial.println("Found fingerprint sensor!");
      } else {
        Serial.println("Did not find fingerprint sensor");
      }
      Serial.println("Waiting for valid finger...");
    }

    int getFingerprintID() {
      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);
      return finger.fingerID; 
    }

4 Likes