void readFingerPrint() { static uint8_t codeBlock = 1; static uint8_t ret = 0; /*Set fingerprint LED ring mode, color, and number of blinks Can be set as follows: Parameter 1:<LEDMode> eBreathing eFastBlink eKeepsOn eNormalClose eFadeIn eFadeOut eSlowBlink Parameter 2:<LEDColor> eLEDGreen eLEDRed eLEDYellow eLEDBlue eLEDCyan eLEDMagenta eLEDWhite Parameter 3:<number of blinks> 0 represents blinking all the time This parameter will only be valid in mode eBreathing, eFastBlink, eSlowBlink */ Serial.print("codeBlock"); Serial.println(codeBlock); Serial.println("ret:"); Serial.println(ret); switch(codeBlock){ case 1: fingerprint.ctrlLED(/*LEDMode = */fingerprint.eBreathing, /*LEDColor = */fingerprint.eLEDBlue, /*blinkCount = */0); //Serial.println("Please press down your finger"); /*Capture fingerprint image, Disable the collection timeout function If succeed return 0, otherwise return ERR_ID809 */ ++codeBlock; return; case 2: if(((fingerprint.collectionFingerprint(/*timeout=*/0)) != ERR_ID809)){ ++codeBlock; return; } else return; // fingerprint.collectionFingerprint(0); /*Set fingerprint LED ring to quick blink in yellow 3 times*/ case 3: fingerprint.ctrlLED(/*LEDMode = */fingerprint.eFastBlink, /*LEDColor = */fingerprint.eLEDYellow, /*blinkCount = */3); // Serial.println("Capturing succeeds"); // Serial.println("Please release your finger"); /*Wait for finger to release Return 1 when finger is detected, otherwise return 0 */ ++codeBlock; return; case 4: while (fingerprint.detectFinger()); //fingerprint.detectFinger(); /*Compare the captured fingerprint with all the fingerprints in the fingerprint library Return fingerprint ID(1-80) if succeed, return 0 when failed */ ++codeBlock; return; case 5: ret = fingerprint.search(); /*Compare the captured fingerprint with a fingerprint of specific ID Return fingerprint ID(1-80) if succeed, return 0 when failed */ //ret = fingerprint.verify(/*Fingerprint ID = */1); ++codeBlock; return; case 6: if (ret != 0) { /*Set fingerprint LED ring to always ON in green */ fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDGreen, /*blinkCount = */0); Serial.print("Matching succeeds,ID="); Serial.println(ret); //delay(1000); //return 1; button_pressed = 1; } else { /*Set fingerprint LED ring to always ON in red*/ fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDRed, /*blinkCount = */0); Serial.println("Matching fails"); //delay(1000); //return 0; button_pressed = 0; } codeBlock = 1; break; default: codeBlock = 1 ; break; } // //Serial.println("-----------------------------"); // delay(1000); }