Created
September 18, 2020 03:41
-
-
Save ajangrahmat/3b654e3b43a8c85889c96b0e7e8d6550 to your computer and use it in GitHub Desktop.
Program Delete Fingerprint
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
#include "Adafruit_Fingerprint.h" | |
#include "SoftwareSerial.h" | |
SoftwareSerial mySerial(2, 3); | |
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); | |
void setup() { | |
Serial.begin(9600); | |
finger.begin(57600); | |
if (finger.verifyPassword()) { | |
Serial.println("FingerPrint Sensor Ditemukan!"); | |
} else { | |
Serial.println("FingerPrint Sensor Tidak Ditemukan! :("); | |
while (1) { | |
delay(1); | |
} | |
} | |
} | |
void loop() { | |
DELETE(); | |
} | |
//------------------------------------------DELETE-----------------------------------// | |
void DELETE() { | |
Serial.println("Please type in the ID # (from 1 to 127) you want to delete..."); | |
uint8_t id = readnumber(); | |
if (id == 0) {// ID #0 not allowed, try again! | |
return; | |
} | |
Serial.print("Deleting ID #"); | |
Serial.println(id); | |
deleteFingerprint(id); | |
} | |
//------------------------------------------PROSES DELETE---------------------------// | |
uint8_t readnumber(void) { | |
uint8_t num = 0; | |
while (num == 0) { | |
while (! Serial.available()); | |
num = Serial.parseInt(); | |
} | |
return num; | |
} | |
//----RETURN NUM-------------------// | |
uint8_t deleteFingerprint(uint8_t id) { | |
uint8_t p = -1; | |
p = finger.deleteModel(id); | |
if (p == FINGERPRINT_OK) { | |
Serial.println("Deleted!"); | |
} else if (p == FINGERPRINT_PACKETRECIEVEERR) { | |
Serial.println("Communication error"); | |
return p; | |
} else if (p == FINGERPRINT_BADLOCATION) { | |
Serial.println("Could not delete in that location"); | |
return p; | |
} else if (p == FINGERPRINT_FLASHERR) { | |
Serial.println("Error writing to flash"); | |
return p; | |
} else { | |
Serial.print("Unknown error: 0x"); Serial.println(p, HEX); | |
return p; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment