I did a project with an Arduino Leonardo and a fingerprint sensor (DY50). When I uploaded the enroll example from the Adafruit Fingerprint Library and saved my fingerprint, everything worked. But when I upload my code, it doesn't print anything.

My Code

#include <Keyboard.h>
#include <Adafruit_Fingerprint.h>
#define mySerial Serial1

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
int fingerprintID = 0;
String inData;
bool isRight;
int pos;

//Number of services to log in
#define servNum 5

//Login URLs for Google, Amazon, Stackoverflow, Arduino and Github
String LogInURL[] = {"https://accounts.google.com/signin", "https://www.amazon.de/ap/signin", "https://stackoverflow.com/users/login", "https://login.arduino.cc/", "https://github.com/login"};
String LogInUser[] = {"user.name@gmail.com", "user.name@example.com", "user.name@example.com", "username", "username"};
String LogInPwd[] = {"password", "password", "password", "password", "password"};

void donothing() {};

void StepsBefore(int serviceNum){
    case 0: donothing(); break;
    case 1: donothing(); break;
    case 2: for(int k=0; k<18; k++) Keyboard.press(KEY_TAB); Keyboard.release(KEY_TAB); break;
    case 3: for(int k=0; k<2; k++) Keyboard.press(KEY_TAB); Keyboard.release(KEY_TAB); break;
    case 4: donothing(); break;
    default: Serial.println("Error: Number not recognized."); break;

void StepsAfter(int serviceNum){
    case 0: Keyboard.println(); break;
    case 1: Keyboard.println(); break;
    case 2: Keyboard.press(KEY_TAB); Keyboard.release(KEY_TAB); break;
    case 3: Keyboard.press(KEY_TAB); Keyboard.release(KEY_TAB); break;
    case 4: for(int k=0; k<2; k++) Keyboard.press(KEY_TAB); Keyboard.release(KEY_TAB); break;
    default: Serial.println("Error: Number not recognized."); break;

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;
  Serial.print("Found ID #"); 
  Serial.print(" with confidence of "); 
  return finger.fingerID; 

void askForFingerprint() {
  fingerprintID = getFingerprintIDez();
    if(fingerprintID == 1){
      isRight = true;

void delAfterChar(String inString, String fromToKill){
  pos = inString.indexOf(fromToKill);
  inString.remove(pos, 1000);
  inData = inString;

void setup() {
    Serial.println("Debug 1");
    Serial.println("Debug 2");
    Serial.println("Debug 3");
    if(finger.verifyPassword()) {
        Serial.println("Found fingerprint sensor!");
    else {
        Serial.println("Did not find fingerprint sensor :(");
        while (1) { delay(1); }
void loop() {
  inData = Serial.read();
  delAfterChar(inData, "?openid"); //Amazon
  delAfterChar(inData, "/v2/"); //Google
  delAfterChar(inData, "?ssrc"); //Stackoverflow
  delAfterChar(inData, "login?state"); //Arduino
    for (int i=0; i<servNum; i++){
     if(inData == LogInURL[i]){
        if(isRight == true){
        else Serial.println("Finger not recognized");

What I've tried so far

  • I changed the baud rate from 9600 to 15200, didn't help
  • Added a few debug points in the setup to check for an error there, nothing changed
  • Uploaded a simple Hello World via Serial Monitor sketch, worked perfectly

What could be the issue? It compiles with no error message. If you see any coding mistakes, feedback would be great.

Using SoftwareSerial instead didn't help either.

  • @jsotola I did that, as explained in the third point of what I've already tried. Sorry if it's not understandable, I don't speak English natively. Mar 14 at 16:13
  • 1
    add while (!Serial); after Serial.begin
    – Juraj
    Mar 14 at 16:48
  • Thanks, @Juraj, totally forgot about this. But why did printing Hello World work without that? Mar 14 at 16:55
  • the Hello World print was in loop? it doesn't take long to connect, but the code runs fast
    – Juraj
    Mar 14 at 17:02
  • @Juraj Yes, it was. Mar 14 at 17:04

As @Juraj pointed out, I just forgot to use while (!Serial) in the setup, probably because I use other boards that don't need this more often.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.