Project code for fingerprint sensor without softwareserial

i am doing a fingerprint sensor project now, i editing from the arduino sample.
the sample given in arduino is using software serial which need to connect to pc for software uses.
but my project need to have hardware uses, those instruction can just display through the lcd display,
can anyone help & guide me in this program code.

i just add in 2 button for enrol n delete function based on arduino example as the file i attached.

If you can't use SoftwareSerial (why not ?) then use hardware serial.

huh... got hardwareserial?
any example about it?
is the hardwareserial same function as softwareserial?

Hardware serial functions Serial

can u have me some similiar example, i need some guide...
im not gud in programming....

Can you please explain exactly what you are trying to do ?
Please post the program associated with the picture of the circuit you posted.

okay, below is the briefly result i would like to get for my program.

  1. when the enrol button pressed, lcd display "Insert FPrint for enrol", then place the finger on the sensor module, lcd display "FPrint Saved..." after success read and save the finger print into microp.

  2. when the delete button pressed, lcd display "Insert FPrint for delete", then place the finger on the sensor module, lcd display "FPrint Deleted..." after success read and delete the finger print from microp.

  3. when no button pressed, the project is run verify function. lcd display "Insert FPrint for verify", then place the finger on the sensor module, lcd display "Verify Success" after success read and turn on the small push-pull solenoid. lcd display "Invalid FPrint" when the fingerprint is not matched with the database

Can you please provide a link to the fingerprint reader ? If it a serial device then you should be able to do what you want using either SoftSerial or the built in hardware serial. One advantage of using SotwareSerial is that it leaves hardware serial free to use the serial monitor for debugging.

above is the fingerprint sensor i used.
if using softwareserial, then need to connect with pc by using USB only can function, right?
but my tutor want me to make it get through to the LCD display, he want me make a standalone project, dun want connect with pc.

jackich:
if using softwareserial, then need to connect with pc by using USB only can function, right?

Wrong

but my tutor want me to make it get through to the LCD display, he want me make a standalone project, dun want connect with pc.

So, what is the problem in using SoftSerial to connect to the fingerprint reader and the LCD to display messages ? If you don't want or need to then nothing need be connected to the PC once the program has been loaded.

Note that you will need to use an external power supply for the reader and solenoid as the Arduino cannot supply the current required to operate them.

my problem is i get the example code of adafruit fingerprint and use it, but the word cannot display on lcd, i tried chg to lcd.print, but the word cannot get in proper way… and cannot function…
actually i not so understand about the example given too, even i copy the same code in, i also cannot get the results…

Please post your program that does not work with the LCD and reader. Have you ever got any text to display on the LCD ?

i had found the code for verify function as default, now i need to add in 2 button for enrol and delete function. i need some idea how to add in…

#include <LiquidCrystal.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
 #include <NewSoftSerial.h>
#endif

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)

// pin #3 is OUT from arduino (WHITE wire)

SoftwareSerial mySerial(2, 3);

LiquidCrystal lcd(5, 6, 7, 8, 9, 10); // initialize the library with the numbers of the interface pins

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()

{ Serial.begin(9600); // initialize the serial communications:

lcd.begin(16,2); lcd.setCursor(0,0); lcd.print("Scan your finger");

pinMode(13,OUTPUT);

pinMode(12,OUTPUT);

pinMode(11, OUTPUT);

pinMode(A0, INPUT);

finger.begin(57600); // set the data rate for the sensor serial port 
}

void loop() // run over and over again

{

getFingerprintID();

delay(100);

digitalWrite (13,HIGH);

}

uint8_t getFingerprintID()

{ uint8_t p = finger.getImage();

switch (p)

{

case FINGERPRINT_OK:

lcd.clear();

lcd.print(" Image taken... ");

delay(1000);

break;

case FINGERPRINT_NOFINGER:

return p;

case FINGERPRINT_PACKETRECIEVEERR:

return p;

case FINGERPRINT_IMAGEFAIL:

return p;

default:

return p; }

// OK success!

p = finger.image2Tz();

switch (p) {

case FINGERPRINT_OK:

break;

case FINGERPRINT_IMAGEMESS:

return p;

case FINGERPRINT_PACKETRECIEVEERR:

return p;

case FINGERPRINT_FEATUREFAIL:

return p;

case FINGERPRINT_INVALIDIMAGE:

return p;

default:

return p; }

// OK converted!

p = finger.fingerFastSearch();

if (p == FINGERPRINT_OK)

{

lcd.clear();

lcd.print(" Found match! ");

digitalWrite(11, HIGH);

delay(1000);

digitalWrite(11,LOW); // turn on green LED to indicate match

}

else if(p == FINGERPRINT_NOTFOUND)

{

lcd.clear();

lcd.setCursor(0,0);

lcd.print(" Did not match! ");

delay(1000);

lcd.clear();

lcd.setCursor(0,0);

lcd.print(" scan finger! ");

return p;

}

else

{ return p; }

// IF FOUND A MATCH............

lcd.clear();

lcd.setCursor(0,0);

lcd.print("Found ID #");

lcd.print(finger.fingerID);

lcd.setCursor(0,1);

lcd.print("confidence ");

lcd.print(finger.confidence); }

// 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!

digitalWrite(13, LOW);

delay(10);

digitalWrite(13, HIGH);

delay(10);

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Found ID # ");

lcd.print(finger.fingerID);

lcd.setCursor(0, 1);

lcd.print("confidence ");

lcd.print(finger.confidence);

return finger.fingerID;

}

now i need to add in 2 button for enrol and delete function. i need some idea how to add in...

What have you tried? Are you able to read the switch states? Do you have an enroll() function to add a fingerprint? Do you have a delete() function to delete a fingerprint?

#include <LiquidCrystal.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
 #include <NewSoftSerial.h>
#endif

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)

SoftwareSerial mySerial(2, 3);

LiquidCrystal lcd(5, 6, 7, 8, 9, 10); // initialize the library with the numbers of the interface pins

int buttonState = 0;

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()

{ 
Serial.begin(9600); // initialize the serial communications:
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Scan your finger");
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11, OUTPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
finger.begin(57600); // set the data rate for the sensor serial port 
}

void loop() // run over and over again

{
buttonState = digitalRead(A1);
uint8_t id = 0;
if (buttonState == HIGH)
{
  getFingerprintEnroll(id);
  delay(100);
  digitalWrite (11,HIGH);
}

else{
getFingerprintID();
delay(100);
digitalWrite (13,HIGH);
}
}

uint8_t getFingerprintID()
{ uint8_t p = finger.getImage();

switch (p)

{

case FINGERPRINT_OK:

lcd.clear();
lcd.print(" Image taken... ");

delay(1000);
break;

case FINGERPRINT_NOFINGER:
return p;

case FINGERPRINT_PACKETRECIEVEERR:
return p;

case FINGERPRINT_IMAGEFAIL:
return p;

default:
return p; }

// OK success!

p = finger.image2Tz();

switch (p) {

case FINGERPRINT_OK:
break;

case FINGERPRINT_IMAGEMESS:
return p;

case FINGERPRINT_PACKETRECIEVEERR:
return p;

case FINGERPRINT_FEATUREFAIL:
return p;

case FINGERPRINT_INVALIDIMAGE:
return p;

default:
return p; }

// OK converted!

p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK)

{

lcd.clear();
lcd.print(" Found match! ");
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11,LOW); // turn on green LED to indicate match

}

else if(p == FINGERPRINT_NOTFOUND)

{

lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Did not match! ");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" scan finger! ");
return p;

}

else

{ return p; }

// IF FOUND A MATCH............

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Found ID #");
lcd.print(finger.fingerID);
lcd.setCursor(0,1);
lcd.print("confidence ");
lcd.print(finger.confidence); }

// 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!

digitalWrite(13, LOW);
delay(10);
digitalWrite(13, HIGH);
delay(10);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Found ID # ");
lcd.print(finger.fingerID);
lcd.setCursor(0, 1);
lcd.print("confidence ");
lcd.print(finger.confidence);
return finger.fingerID;

}

uint8_t getFingerprintEnroll(uint8_t id) {
  uint8_t p = -1;
  lcd.clear();
  lcd.print("Scan for Enroll");
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    
    switch (p) {
      
    case FINGERPRINT_OK:
    lcd.clear();
    lcd.print(" Image taken... ");

    delay(1000);
    break;
    
    case FINGERPRINT_NOFINGER:
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      return p;
    case FINGERPRINT_IMAGEFAIL:
      return p;
    default:
      return p;
    }
  }

  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
    case FINGERPRINT_OK:
      break;
    case FINGERPRINT_IMAGEMESS:
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      return p;
    case FINGERPRINT_FEATUREFAIL:
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      return p;
    default:
      return p;
  }
  
  lcd.clear();
  lcd.print("Remove finger ");
  delay(2000);

  
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }

  p = -1;
  lcd.clear();
  lcd.print("Rescan finger");
  
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
    
    lcd.clear();
    lcd.print(" Image taken... ");

    delay(1000);
    break;

    case FINGERPRINT_NOFINGER:
    return p;

    case FINGERPRINT_PACKETRECIEVEERR:
    return p;

    case FINGERPRINT_IMAGEFAIL:
    return p;

    default:
    return p; 
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
    case FINGERPRINT_OK:
    break;

    case FINGERPRINT_IMAGEMESS:
    return p;

    case FINGERPRINT_PACKETRECIEVEERR:
    return p;

    case FINGERPRINT_FEATUREFAIL:
    return p;

    case FINGERPRINT_INVALIDIMAGE:
    return p;

    default:
    return p; }
  
  
  // OK converted!
  p = finger.createModel();
  if (p == FINGERPRINT_OK) {
    lcd.clear();
    lcd.print("Prints matched!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    return p;
  } else if (p == FINGERPRINT_ENROLLMISMATCH) {
    return p;
  } else {
    return p;
  }   
  
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    lcd.clear();
    lcd.print("Stored!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    return p;
  } else {
    return p;
  }   
}

this is the current code i tried for enrol button with verify function,
for the default verify function is okay, since there are no data stored, i can get the result as below

  1. scan your finger
    2)image taken…
    3)did not match!
  2. scan finger!

but for the enrol button i set up cannot function well, as i pressed the button, the led i set on pin 11 is on, so i can make sure the button is function, but i cannot get any result for lcd, it did not give out the result for getFingerprintEnroll(id), the results still remains at last state.

can any1 help me to check which part i done wrong, pls correct me…

I
gave
up
trying
to
read
your
poorly
indented
code.

Use Tools + Auto Format to properly format your code, and post it again.

NOTHING goes on the line after the {. Nothing goes on the same line as the }.

#include <LiquidCrystal.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)

SoftwareSerial mySerial(2, 3);

LiquidCrystal lcd(5, 6, 7, 8, 9, 10); // initialize the library with the numbers of the interface pins

int buttonState = 0;

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()

{ 
  Serial.begin(9600); // initialize the serial communications:
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Scan your finger");
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  finger.begin(57600); // set the data rate for the sensor serial port 
}

void loop() // run over and over again

{
  buttonState = digitalRead(A1);
  uint8_t id = 0;
  if (buttonState == HIGH)
  {
    id++;
    getFingerprintEnroll(id);
    delay(100);
    digitalWrite (11,HIGH);
  }

  else{
    getFingerprintID();
    delay(100);
    digitalWrite (13,HIGH);
  }
}

uint8_t getFingerprintID()
{ 
  uint8_t p = finger.getImage();

  switch (p)

  {

  case FINGERPRINT_OK:

    lcd.clear();
    lcd.print(" Image taken... ");

    delay(1000);
    break;

  case FINGERPRINT_NOFINGER:
    return p;

  case FINGERPRINT_PACKETRECIEVEERR:
    return p;

  case FINGERPRINT_IMAGEFAIL:
    return p;

  default:
    return p; 
  }

  // OK success!

  p = finger.image2Tz();

  switch (p) {

  case FINGERPRINT_OK:
    break;

  case FINGERPRINT_IMAGEMESS:
    return p;

  case FINGERPRINT_PACKETRECIEVEERR:
    return p;

  case FINGERPRINT_FEATUREFAIL:
    return p;

  case FINGERPRINT_INVALIDIMAGE:
    return p;

  default:
    return p; 
  }

  // OK converted!

  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK)

  {

    lcd.clear();
    lcd.print(" Found match! ");
    digitalWrite(11, HIGH);
    delay(1000);
    digitalWrite(11,LOW); // turn on green LED to indicate match

  }

  else if(p == FINGERPRINT_NOTFOUND)

  {

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(" Did not match! ");
    delay(1000);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(" scan finger! ");
    return p;

  }

  else

  { 
    return p; 
  }

  // IF FOUND A MATCH............

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Found ID #");
  lcd.print(finger.fingerID);
  lcd.setCursor(0,1);
  lcd.print("confidence ");
  lcd.print(finger.confidence); 
}

// 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!

  digitalWrite(13, LOW);
  delay(10);
  digitalWrite(13, HIGH);
  delay(10);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Found ID # ");
  lcd.print(finger.fingerID);
  lcd.setCursor(0, 1);
  lcd.print("confidence ");
  lcd.print(finger.confidence);
  return finger.fingerID;

}

uint8_t getFingerprintEnroll(uint8_t id) {
  uint8_t p = -1;
  lcd.clear();
  lcd.print("Scan for Enroll");
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();

    switch (p) {

    case FINGERPRINT_OK:
      lcd.clear();
      lcd.print(" Image taken... ");

      delay(1000);
      break;

    case FINGERPRINT_NOFINGER:
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      return p;
    case FINGERPRINT_IMAGEFAIL:
      return p;
    default:
      return p;
    }
  }

  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
  case FINGERPRINT_OK:
    break;
  case FINGERPRINT_IMAGEMESS:
    return p;
  case FINGERPRINT_PACKETRECIEVEERR:
    return p;
  case FINGERPRINT_FEATUREFAIL:
    return p;
  case FINGERPRINT_INVALIDIMAGE:
    return p;
  default:
    return p;
  }

  lcd.clear();
  lcd.print("Remove finger ");
  delay(2000);


  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }

  p = -1;
  lcd.clear();
  lcd.print("Rescan finger");

  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:

      lcd.clear();
      lcd.print(" Image taken... ");

      delay(1000);
      break;

    case FINGERPRINT_NOFINGER:
      return p;

    case FINGERPRINT_PACKETRECIEVEERR:
      return p;

    case FINGERPRINT_IMAGEFAIL:
      return p;

    default:
      return p; 
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
  case FINGERPRINT_OK:
    break;

  case FINGERPRINT_IMAGEMESS:
    return p;

  case FINGERPRINT_PACKETRECIEVEERR:
    return p;

  case FINGERPRINT_FEATUREFAIL:
    return p;

  case FINGERPRINT_INVALIDIMAGE:
    return p;

  default:
    return p; 
  }


  // OK converted!
  p = finger.createModel();
  if (p == FINGERPRINT_OK) {
    lcd.clear();
    lcd.print("Prints matched!");
  } 
  else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    return p;
  } 
  else if (p == FINGERPRINT_ENROLLMISMATCH) {
    return p;
  } 
  else {
    return p;
  }   

  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    lcd.clear();
    lcd.print("Stored!");
  } 
  else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    return p;
  } 
  else if (p == FINGERPRINT_BADLOCATION) {
    return p;
  } 
  else if (p == FINGERPRINT_FLASHERR) {
    return p;
  } 
  else {
    return p;
  }   

}

okay i had autoformat and make some change.
now when i press the enrol button, lcd shows “Scan for enroll”, this is the only success.
after i scan the fingerprint, it show “image taken…” then follow by “Did not match!” then “scan finger!” seems like something wrong when the “did not match!” come out…