Fingerprint ID Safe

The Fingerprint ID Safe is a lock that works by either scanning your fingerprint,  or entering a code. It uses 4 components: Keypad, Fingerprint Scanner, Servo Motor, and an Arduino.

Engineer

George G.

Area of Interest

Mechanical Engineering, Computer Science.

School

Monta Vista High School

Grade

Incoming Sophmore

Final Milestone

Final Milestone

Fingerprint ID Safe Code

#include <Key.h>
#include <Keypad.h>
#include <Adafruit_Fingerprint.h>

#include <Servo.h>
SoftwareSerial mySerial(10, 11);
int pos = 0;
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

Servo ServoMotor;

char* password = “111”;
int position = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{‘1′,’2′,’3′,’A’},
{‘4′,’5′,’6′,’B’},
{‘7′,’8′,’9′,’C’},
{‘*’,’0′,’#’,’D’}
};

byte rowPins[ROWS] = { 8, 7, 6, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
ServoMotor.attach(12);

ServoMotor.write(0);

Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/…
delay(100);
Serial.println(“\n\nAdafruit finger detect test”);

// set the data rate for the sensor serial port
finger.begin(57600);
delay(5);
if (finger.verifyPassword()) {
Serial.println(“Found fingerprint sensor!”);
} else {
Serial.println(“Did not find fingerprint sensor :(“);
while (1) { delay(1); }
}

finger.getTemplateCount();

if (finger.templateCount == 0) {
Serial.print(“Sensor doesn’t contain any fingerprint data. Please run the ‘enroll’ example.”);
}
else {
Serial.println(“Waiting for valid finger…”);
Serial.print(“Sensor contains “); Serial.print(finger.templateCount); Serial.println(” templates”);
}

ServoMotor.attach(12);

LockedPosition(true);

}

void loop()
{
getFingerprintIDez();
Serial.println(“2”);
delay(50); //don’t ned to run this at full speed.
if (finger.confidence>60){
Serial.println(“1”);

ServoMotor.write(90);

delay(15);

}
if (finger.confidence>80){
Serial.println(“5”);
ServoMotor.write(0);

delay(15);
}
char key = keypad.getKey();
if (key == ‘*’ || key == ‘#’)
{
ServoMotor.write(180);
LockedPosition(true);
}
if (key == password[position])
{
position ++;
}
if (position == 3)
{
LockedPosition(false);
}
delay(100);

}
void LockedPosition(int locked)
{
if (locked)
{

ServoMotor.write(11);

}
else
{
Serial.println(“4”);
ServoMotor.write(0);

}
}
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);

return finger.fingerID;
}

// 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);
return finger.fingerID;
}

For my 3rd and Final Milestone I finished the project and have a full functioning product. I attached the servo on to the box so it can be locked. Since I couldn’t drill any holes on to my safe, I had to figure out creative ways to lock the both. I decided on have a hot glued perf board on the side of the box. With the fingerprint is scanned and the fingerprint confidence is greater than 60 the servo would turn 90 degrees. The servo had extensions and a L shaped stick so the “hook” can lock onto the perf board. This would lock and it, and unable to open. After you scan your fingerprint again, the servo would unlock.

Second Milestone

Second Milestone

My second milestone, uses all the components that are needed except for the box. The keypad is assigned to 8 pins on the arduino and that is what assigns the password. The fingerprint sensor is attached to 2 other pins which declares the fingerprint. The servo is the locking mechanism on the project itself. It would turn the lock 180 degrees for the lock to unlock. For further modifications, I plan to use either LEDs or an LCD display to clearly show what is happening, rather show it on the serial monitor.

First Milestone

First Milestone

Keypad Code

#include <Servo.h>
#include <Keypad.h>

Servo ServoMotor;
char* password = “111”; // change the password here, just pick any 3 numbers
int position = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{‘1′,’2′,’3′,’A’},
{‘4′,’5′,’6′,’B’},
{‘7′,’8′,’9′,’C’},
{‘*’,’0′,’#’,’D’}
};

byte rowPins[ROWS] = { 8, 7, 6, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int RedpinLock = 12;
int GreenpinUnlock = 13;

void setup()
{
pinMode(RedpinLock, OUTPUT);
pinMode(GreenpinUnlock, OUTPUT);
ServoMotor.attach(12);
LockedPosition(true);
}

void loop()
{
char key = keypad.getKey();
if (key == ‘*’ || key == ‘#’)
{
position = 90;
LockedPosition(true);
}
if (key == password[position])
{
position ++;
}
if (position == 3)
{
LockedPosition(false);
}
delay(100);
}
void LockedPosition(int locked)
{
if (locked)
{
digitalWrite(RedpinLock, HIGH);
digitalWrite(GreenpinUnlock, LOW);
ServoMotor.write(90);
}
else
{
digitalWrite(RedpinLock, LOW);
digitalWrite(GreenpinUnlock, HIGH);
ServoMotor.write(0);
}
}

My first milestone is split up into 2 parts: The Fingerprint Scanner, and the Keypad. My fingerprint scanner has a very simple code, which directs the scanner to scan the finger, and assign in to a ID number ex.1,2,etc. The fingerprint would then store the fingerprint onto the arduino. It takes pictures to the finger and assigns it. The keypad is a little more complex, and it takes in a 3 digit value. For my keypad I did (1,1,1). If any other keys are pressed, then nothing would happen. After (1,1,1) is pressed the connected servo motor will turn 45* or half a turn. If # or * is clicked the lock would turn back to normal. The keypad works by using wires that connect each wire to the output jumper wires. If a key is pressed it sends a signal to its corresponding wire, but there are only 8 jumper wires and 16 keys. If a key is pressed and doesn’t have a corresponding wire, then it would send a signal to two wires to have it pressed. 

img_0210

Start typing and press Enter to search

Bluestamp Engineering