Created
February 26, 2018 21:05
-
-
Save ShawnHymel/6598b93dcaf6346cd1d0c1bf57388ce5 to your computer and use it in GitHub Desktop.
Identify a fingerprint using the GT-521F32 sensor and display a welcome message on an OLED screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fingerprint Door Demo | |
* Date: February 26, 2018 | |
* Author: Shawn Hymel (SparkFun Electronics) | |
* | |
* Connect a GT-521F32 fingerprint and servo to an Arduino Pro | |
* Mini (3.3V). Install the FPS_GT511C3 library and run the | |
* FPS_Enroll example to enroll a fingerprint. Upload this | |
* program to display a message on the OLED on correct | |
* fingerprint identification. | |
* | |
* Arduino Pro Mini (3.3V) | Fingerprint Scanner | |
* ------------------------|-------------------- | |
* pin 4 | UART_TX | |
* pin 5 | UART_RX | |
* GND | GND | |
* 3.3V | Vin | |
* | |
* Arduino Pro Mini (3.3V) | Micro OLED Breakout | |
* ------------------------|-------------------- | |
* GND | GND | |
* 3.3V | VCC | |
* pin 7 | RST | |
* pin 8 | D/C | |
* pin 10 | CS | |
* pin 11 | D1/SDI | |
* pin 13 | D0/SCK | |
* | |
* This sketch was written by SparkFun Electronics, with lots of | |
* help from the Arduino community. This code is completely free | |
* for any use. | |
*/ | |
#include <SPI.h> // Include SPI if you're using SPI | |
#include <SFE_MicroOLED.h> // Include the SFE_MicroOLED library | |
#include "FPS_GT511C3.h" | |
#include "SoftwareSerial.h" | |
// Your name | |
const String MY_NAME = "Shawn"; | |
// Your registered ID in the GT-521F32 fingerprint scanner | |
const int MY_ID = 0; | |
// Pin Definitions | |
const int FPS_TX = 4; | |
const int FPS_RX = 5; | |
const int OLED_RST = 7; | |
const int OLED_DC = 8; | |
const int OLED_CS = 10; | |
// Parameters | |
const int WAIT = 3000; // ms delay to show message | |
// Globals | |
MicroOLED oled(OLED_RST, OLED_DC, OLED_CS); | |
FPS_GT511C3 fps(FPS_TX, FPS_RX); | |
void setup() { | |
// Initialize and clear OLED | |
oled.begin(); | |
oled.clear(ALL); | |
oled.display(); | |
delay(1000); | |
oled.clear(PAGE); | |
// Initialize fingerprint scanner | |
fps.Open(); | |
fps.SetLED(true); | |
} | |
void loop() { | |
// Identify fingerprint | |
if ( fps.IsPressFinger() ) { | |
// If fingerprint is found, identify it | |
fps.CaptureFinger(false); | |
int id = fps.Identify1_N(); | |
if ( id == MY_ID ) { | |
printCorrectMessage(); | |
} else { | |
printWrongMessage(); | |
} | |
delay(WAIT); | |
} else { | |
// If no fingerprint is found, wait for one | |
printWaitMessage(); | |
delay(100); | |
} | |
} | |
void printCorrectMessage() { | |
oled.setFontType(1); | |
oled.clear(PAGE); | |
oled.setCursor(0, 0); | |
oled.print("Welcome"); | |
oled.println("home,"); | |
oled.print(MY_NAME); | |
oled.display(); | |
} | |
void printWrongMessage() { | |
oled.setFontType(1); | |
oled.clear(PAGE); | |
oled.setCursor(0, 0); | |
oled.print("Get off"); | |
oled.println("my"); | |
oled.print("lawn."); | |
oled.display(); | |
} | |
void printWaitMessage() { | |
oled.setFontType(1); | |
oled.clear(PAGE); | |
oled.setCursor(0, 0); | |
oled.print("Present"); | |
oled.print("finger"); | |
oled.display(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm currently working with this FPS hokked up to a sparkfun black board and two Qwiic relays to release two security drawers. the question io have is how to activate the standby mode on the LED as they are constantly on but I (or my code friendly friend) cannot seem to make the code work. any suggestions/advice welcome.
kindest
Dan