#include <Adafruit_Fingerprint.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h> // Comes with Arduino IDE
SoftwareSerial sms(2, 3);
SoftwareSerial mySerial(4, 5);// Tx, Rx
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int electronic_lock = 8;
int numdata;
boolean started = false;
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
bool found = 0;
bool matched = 0;
int return_id;
uint8_t id;
void setup()
{
pinMode(8, OUTPUT);
Serial.begin(9600);
while (!Serial);
delay(100);
// set the data rate for the sensor serial port
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor");
} else {
Serial.println("Did not find fingerprint sensor");
while (1) { delay(1); }
}
finger.getTemplateCount();
Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" template(s)");
Serial.println("Waiting for valid finger...");
sms.begin(9600);
pinMode(8, OUTPUT);
lcd.begin(20, 4); // Initialize 20X4 LCD and turn on backlight
lcd.backlight();
Serial.begin(9600);
Serial.println("Adafruit finger detect test");
// set the data rate for the sensor serial port
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1);
}
lcd.setCursor(0, 0);
lcd.print("Biomatric Door Lock ");
lcd.setCursor(0, 1);
lcd.print(" System ");
delay(3000);
lcd.clear();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Place the finger");
}
void loop() // run over and over again
{
getFingerprintIDez();
delay(50); //don't ned to run this at full speed.
}
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);
digitalWrite(electronic_lock, HIGH);
delay(1500); //Change the door lock delay from here
digitalWrite(electronic_lock, LOW);
Serial.println("Unlocked");
return finger.fingerID;
if (found == 1)
{
if (matched == 1)
{
lcd.setCursor(0, 1);
lcd.print("Access Granted");
digitalWrite(8, HIGH);
delay(2000);
digitalWrite(8, LOW);
sms.print("0");
}
else
{
sms.print("1");
lcd.setCursor(0, 1);
lcd.print("Access Denied");
digitalWrite(8, LOW);
}
}
else
{
lcd.setCursor(0, 0);
lcd.print("Place the finger");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print(" ");
}
delay(50);
}
testing.ino (3.14 KB)