how do i get the "Didn't Find a Match" response??

Hi every one!

I'm having a programming problem..

My project is a fingerprint scanner door security.
when a finger print match the system will unlock the door and send a message to the user.
i also want it to send a message when ID doesn't match..

please help me..

heres my code:

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <Streaming.h>
#include <Servo.h>

#define __Debug         1                               // if debug mode

const int pinServo      = 6;                            // servo pin
const int angleServo    = 60;                           // Rotation angle

#if __Debug
#define DBG(X)          Serial.println(X)
#else
#define DBG(X)
#endif

SoftwareSerial mySerial(2, 3);                                // tx, rx
SoftwareSerial SIM900(7, 8);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
Servo myservo;                                                  // create servo object to control a servo

void open_close_door()
{
    myservo.attach(pinServo);
    for(int i=5; i<angleServo; i++)
    {
        myservo.write(i);
        delay(5);
    }

    delay(2000);

    for(int i=(angleServo-1); i>=5; i--)
    {
        myservo.write(i);
        delay(5);
    }
    myservo.detach();


}


void setup()
{
    SIM900.begin(19200);
    SIM900power();  
    delay(20000);  // give time to log on to network.
    Serial.begin(9600);
    finger.begin(57600);
    delay(500);
    DBG("setup ok!");
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(5000);
}

void sendSMS()
{
  SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  delay(100);
  SIM900.println("AT + CMGS = \"+639988616678\"");                                     // recipient's mobile number, in international format
  delay(100);
  SIM900.println("Hello, world. This is a text message from an Arduino Uno.");        // message to send
  delay(100);
  SIM900.println((char)26);                       // End AT command with a ^Z, ASCII code 26
  delay(100); 
  SIM900.println();
  delay(5000);                                     // give module time to send SMS
  SIM900power();                                   // turn off module
}

void intruderSMS()
{
  SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  delay(100);
  SIM900.println("AT + CMGS = \"+639988616678\"");                                     // recipient's mobile number, in international format
  delay(100);
  SIM900.println("INTRUDER ALERT!! This is a text message from an Arduino Uno.");        // message to send
  delay(100);
  SIM900.println((char)26);                       // End AT command with a ^Z, ASCII code 26
  delay(100); 
  SIM900.println();
  delay(5000);                                     // give module time to send SMS
  SIM900power();                                   // turn off module
}

void loop()                     // run over and over again
{
    if(getFingerprintIDez()>=0)
    {
        sendSMS();
        open_close_door();
        DBG("Found match!, open door now!!");
        delay(2000);
    }
    delay(50);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez()
{

    if (!finger.verifyPassword())
    {
        DBG("Did not find fingerprint sensor :(");
        return -1;
    }

    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;
    }

#if __Debug
    Serial.print("Found ID #");
    Serial.print(finger.fingerID);
    Serial.print(" with confidence of ");
    DBG(finger.confidence);
#endif

    return finger.fingerID;

}

i also want it to send a message when ID doesn't match..

please help me..

What does it currently do?

Vaclav:

like this?

  else getFingerprintIDez()<0)
    {
    intruderSMS();
    DBG("Intruder Alert!");
    delay(50);
}

it suppose to send an sms and a response to the serial monitor "No ID match, Intruder Alert!"

intruderSMS();
DBG(""No ID match, Intruder Alert!");

Vaclav, why is your post nothing more than quoting someone else's post?

Vaclav's two meaningless posts removed.

if this is my code...

 if(getFingerprintIDez()>=0)
    {
        sendSMS();
        open_close_door();
        DBG("Found match!, open door now!!");
        delay(2000);
}

what will be my else statement to have this

else function??()?)
{
      intruderSMS()
      DBG("No found match!, Intruder Alert!!");

delay(50)
)



thx!

What is it that you want to run if getFingerprintIDez() is not greater or equal to zero ?
What values does getFingerprintIDez() return ? Is the value ever negative ?

In general the if/else syntax is

if (this is true)
{
  //run this code
}
else
{
  //run this code
}

Or if it is more complex you could

if (this is true)
{
  //run 1st code
}
else if (that is true)
{
  //run 2nd code
}
else
{
  //run 3rd code
}

Here is my code

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <Streaming.h>
#include <Servo.h>

#define __Debug         1                               // if debug mode

const int pinServo      = 6;                            // servo pin
const int angleServo    = 60;                           // Rotation angle

#if __Debug
#define DBG(X)          Serial.println(X)
#else
#define DBG(X)
#endif

SoftwareSerial mySerial(2, 3);                                // tx, rx
SoftwareSerial SIM900(7, 8);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
Servo myservo;                                                  // create servo object to control a servo

void open_close_door()
{
    myservo.attach(pinServo);
    for(int i=5; i<angleServo; i++)
    {
        myservo.write(i);
        delay(5);
    }

    delay(2000);

    for(int i=(angleServo-1); i>=5; i--)
    {
        myservo.write(i);
        delay(5);
    }
    myservo.detach();


}


void setup()
{
    SIM900.begin(19200);
    SIM900power();  
    delay(20000);  // give time to log on to network.
    Serial.begin(9600);
    finger.begin(57600);
    delay(500);
    DBG("setup ok!");
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(5000);
}

void sendSMS()
{
  SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  delay(100);
  SIM900.println("AT + CMGS = \"+639988616678\"");                                     // recipient's mobile number, in international format
  delay(100);
  SIM900.println("Hello, world. This is a text message from an Arduino Uno.");        // message to send
  delay(100);
  SIM900.println((char)26);                       // End AT command with a ^Z, ASCII code 26
  delay(100); 
  SIM900.println();
  delay(5000);                                     // give module time to send SMS
  SIM900power();                                   // turn off module
}

void intruderSMS()
{
  SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  delay(100);
  SIM900.println("AT + CMGS = \"+639988616678\"");                                     // recipient's mobile number, in international format
  delay(100);
  SIM900.println("INTRUDER ALERT!! This is a text message from an Arduino Uno.");        // message to send
  delay(100);
  SIM900.println((char)26);                       // End AT command with a ^Z, ASCII code 26
  delay(100); 
  SIM900.println();
  delay(5000);                                     // give module time to send SMS
  SIM900power();                                   // turn off module
}

void loop()                     // run over and over again
{
    if(getFingerprintIDez()>=0)
    {
        sendSMS();
        open_close_door();
        DBG("Found match!, open door now!!");
        delay(2000);
    }
    delay(50);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez()
{

    if (!finger.verifyPassword())
    {
        DBG("Did not find fingerprint sensor :(");
        return -1;
    }

    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;
    }

#if __Debug
    Serial.print("Found ID #");
    Serial.print(finger.fingerID);
    Serial.print(" with confidence of ");
    DBG(finger.confidence);
#endif

    return finger.fingerID;

}