safwan092

Untitled

Jul 28th, 2020
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Adafruit_Fingerprint.h> // <------❌
  2. #include <SoftwareSerial.h>
  3. #include<Servo.h>
  4. #include <Wire.h>
  5. #include <LiquidCrystal_I2C.h>
  6. LiquidCrystal_I2C lcd(0x3F, 20, 4);
  7. Servo servo;
  8. int getFingerprintIDez();
  9.  
  10. SoftwareSerial mySerial(2, 3);
  11. Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
  12.  
  13. void setup()
  14. {
  15. Serial.begin(9600); // <------❌
  16. lcd.begin(16, 2); // initialize the lcd
  17. lcd.init();
  18. // Print a message to the LCD.
  19. lcd.backlight();
  20. lcd.setCursor(3, 0);
  21. lcd.print("Insert your ");
  22. lcd.setCursor(5, 1);
  23. lcd.print("finger ");
  24. finger.begin(57600);
  25. servo.attach(5);
  26. pinMode(6, OUTPUT);
  27. pinMode(7, OUTPUT);
  28. }
  29.  
  30. void loop() {
  31. getFingerprintIDez();
  32. delay(50); //don't ned to run this at full speed.
  33. digitalWrite(6, HIGH);
  34. digitalWrite(7, LOW);
  35. }
  36.  
  37. int getFingerprintIDez() {
  38. uint8_t p = finger.getImage();
  39. if (p != FINGERPRINT_OK) return -1;
  40.  
  41. p = finger.image2Tz();
  42. if (p != FINGERPRINT_OK) return -1;
  43.  
  44. p = finger.fingerFastSearch();
  45. if (p != FINGERPRINT_OK) return -1;
  46.  
  47.  
  48. Serial.print("Found ID #"); Serial.print(finger.fingerID);
  49. Serial.print(" with confidence of "); Serial.println(finger.confidence);
  50. if (finger.fingerID == 2) { // <------❌
  51. servo.write(90);
  52. lcd.clear();
  53. lcd.setCursor(4, 0);
  54. lcd.print("Welcom Ali");
  55. digitalWrite(6, HIGH);
  56. digitalWrite(5, LOW);
  57. delay(5000);
  58. servo.write(0);
  59. lcd.clear();
  60. lcd.setCursor(3, 0);
  61. lcd.print("Insert your ");
  62. lcd.setCursor(5, 1);
  63. lcd.print("finger ");
  64.  
  65. }
  66.  
  67. return finger.fingerID;
  68. }
RAW Paste Data