Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 5:022e24a51359, committed 2021-03-16
- Comitter:
- cdupaty
- Date:
- Tue Mar 16 16:33:34 2021 +0000
- Parent:
- 4:a2d1329d042c
- Commit message:
- version 0.2
Changed in this revision
| Fingerprint.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Fingerprint.lib Tue Mar 16 16:33:34 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/cdupaty/code/Fingerprint/#35cd316e4b41
--- a/main.cpp Wed Jan 22 12:34:48 2020 +0000
+++ b/main.cpp Tue Mar 16 16:33:34 2021 +0000
@@ -1,22 +1,157 @@
-// Serial demo using mbed 5
+/***************************************************
+ This is an example sketch for our optical Fingerprint sensor
+
+ Designed specifically to work with the Adafruit BMP085 Breakout
+ ----> http://www.adafruit.com/products/751
+ These displays use TTL Serial to communicate, 2 pins are required to
+ interface
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+ Written by Limor Fried/Ladyada for Adafruit Industries.
+ BSD license, all text above must be included in any redistribution
+ ****************************************************/
+
+
+#include <Fingerprint.h>
#include "mbed.h"
-
DigitalOut myled(LED1);
Serial pc(USBTX, USBRX); // tx, rx
-int main() {
- char c ;
- pc.printf("Enter a character>");
- while(1) {
- myled = 0; // turn on
- c = pc.getc();
- myled = 1; // turn off
- pc.putc(c);
- pc.putc(c); // echo twice
- pc.putc('\r');
- pc.putc('\n');
- wait(0.5);
- pc.printf("Enter a character>");
+Fingerprint finger(PC_1,PC_0,PB_0,0x0); // TX,TX,RESET,pass
+
+void setup()
+{
+ pc.baud(9600);
+ wait_ms(100);
+ pc.printf("\n\nAdafruit finger detect test");
+
+ // set the data rate for the sensor serial port
+ finger.begin(57600);
+ wait_ms(5);
+ if (finger.verifyPassword()) {
+ pc.printf("Found fingerprint sensor!");
+ } else {
+ pc.printf("Did not find fingerprint sensor :(");
+ while (1)
+ {
+ wait_ms(1);
}
+ }
+
+ pc.printf("Reading sensor parameters");
+ finger.getParameters();
+ pc.printf("Status: 0x%X\n",finger.status_reg);
+ pc.printf("Sys ID: 0x%X\n",system_id);
+ pc.printf("Capacity: %d\n",capacity);
+ pc.printf("Security level: %d\n",security_level);
+ pc.printf("Device address: 0x%X\n",device_addr);
+ pc.printf("Packet len: %d\n",packet_len);
+ pc.printf("Baud rate: %d\n",baud_rate);
+
+ finger.getTemplateCount();
+
+ if (finger.templateCount == 0) {
+ pc.printf("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
+ }
+ else {
+ pc.printf("Waiting for valid finger...");
+ pc.printf("Sensor contains "); pc.printfinger.templateCount); pc.printf(" templates");
+ }
}
+
+int main(void) // run over and over again
+{
+ setup();
+ while(1)
+ {
+ getFingerprintID();
+ wait_ms(50); //don't ned to run this at full speed.
+ }
+ return 0;
+}
+
+uint8_t getFingerprintID() {
+ uint8_t p = finger.getImage();
+ switch (p) {
+ case FINGERPRINT_OK:
+ pc.printf("Image taken");
+ break;
+ case FINGERPRINT_NOFINGER:
+ pc.printf("No finger detected");
+ return p;
+ case FINGERPRINT_PACKETRECIEVEERR:
+ pc.printf("Communication error");
+ return p;
+ case FINGERPRINT_IMAGEFAIL:
+ pc.printf("Imaging error");
+ return p;
+ default:
+ pc.printf("Unknown error");
+ return p;
+ }
+
+ // OK success!
+
+ p = finger.image2Tz();
+ switch (p) {
+ case FINGERPRINT_OK:
+ pc.printf("Image converted");
+ break;
+ case FINGERPRINT_IMAGEMESS:
+ pc.printf("Image too messy");
+ return p;
+ case FINGERPRINT_PACKETRECIEVEERR:
+ pc.printf("Communication error");
+ return p;
+ case FINGERPRINT_FEATUREFAIL:
+ pc.printf("Could not find fingerprint features");
+ return p;
+ case FINGERPRINT_INVALIDIMAGE:
+ pc.printf("Could not find fingerprint features");
+ return p;
+ default:
+ pc.printf("Unknown error");
+ return p;
+ }
+
+ // OK converted!
+ p = finger.fingerSearch();
+ if (p == FINGERPRINT_OK) {
+ pc.printf("Found a print match!");
+ } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
+ pc.printf("Communication error");
+ return p;
+ } else if (p == FINGERPRINT_NOTFOUND) {
+ pc.printf("Did not find a match");
+ return p;
+ } else {
+ pc.printf("Unknown error");
+ return p;
+ }
+
+ // found a match!
+ pc.printf("Found ID #"); pc.printfinger.fingerID);
+ pc.printf(" with confidence of "); pc.printfinger.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!
+ pc.printf("Found ID #"); pc.printfinger.fingerID);
+ pc.printf(" with confidence of "); pc.printfinger.confidence);
+ return finger.fingerID;
+}
\ No newline at end of file