johnwasser:
Make a list of the ID numbers and a list of matching names. Search the list of ID numbers for the ID. Display the matching entry in the list of names.
how to do that? sorry not so familiar with the codes..
int ownerIDs[10] = {20 /* Add other IDs here, separated by commas */ };
char ownerNames[10] = {"maria" / Add other names here, separated by commas */ };
In place of the code snippet you showed:
bool found = false;
for(byte n=0; n<10; n++)
{
if(finger.fingerID == ownerIDs[n])
{
Serial.print("Fingerprint belongs to ");
Serial.print(ownerNames[n]);
Serial.print(" with confidence of ");
Serial.println(finger.confidence);
found = true;
}
}
if(!found)
Serial.println("Fingerprint owner unknown.");
hi paul thanks for your response
i input your codes... but still not showing the name..
take time to analyze my code..hope you can help me
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <Streaming.h>
#include <Servo.h>
const int pinServo = 6; // servo pin
const int angleServo = 60; // Rotation angle
int getFingerprintIDez();
int ownerIDs[10] = {22};
char *ownerNames[10] = {"maria zussete"};
SoftwareSerial mySerial(2, 3);
SoftwareSerial SIM900(7, 8);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
Servo myservo;
void open_close_door()
{
myservo.attach(pinServo);
for(int i=20; i<angleServo; i++)
{
myservo.write(i);
delay(5);
}
delay(2000);
for(int i=(angleServo-1); i>=20; i--)
{
myservo.write(i);
delay(5);
}
myservo.detach();
}
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.print("ACCESS GRANTED!");
SIM900.print("Welcome Home ");
SIM900.println(finger.fingerID);
SIM900.print("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 setup()
{
SIM900.begin(19200);
SIM900power();
delay(20000);
Serial.begin(9600);
finger.begin(57600);
delay(500);
Serial.println("Scan Fingerprint");
}
void loop() // run over and over again
{
getFingerprintID();
delay(100);
}
uint8_t getFingerprintID()
{ uint8_t p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println(" 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)
{
sendSMS();
open_close_door();
Serial.println(" Found match! ");
}
else if(p == FINGERPRINT_NOTFOUND)
{
intruderSMS();
Serial.print(" Did not match! ");
Serial.print("Intruder Alert!!");
return p;
}
else
{ return p; }
// IF FOUND A MATCH............
Serial.print("Fingerprint belongs to ");
Serial.print(ownerNames[10]);
Serial.print(" with confidence of ");
Serial.println(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!
bool found = false;
for (byte n=0; n<10; n++)
{
if (finger.fingerID == ownerIDs[10])
{
Serial.print("Fingerprint belongs to ");
Serial.print(ownerNames[n]);
Serial.print(" with confidence of ");
Serial.println(finger.confidence);
found = true;
return finger.fingerID;
}
}
if(!found)
Serial.println("Fingerprint owner unknown.");
}
Only one instance of SoftwareSerial can listen at a time. If you are listening to the mySerial (otherwise known as a fingerprintReader), you are not listening to the modem. Any incoming phone calls or text messages will hit the bit bucket.
If you are listening to the modem, you can forget about fingerprints being recognized.
You need a Mega or similar Arduino with 4 hardware serial ports.
sorry kinda noob in programming...just want to try this arduino...it impress me and motivate me to create this project..
So why did you butcher code that appears to work? If it doesn't, figure out why. Don't just delete stuff for the hell of it.
Put the code back like in reply #3 (but using the value 22, which you now seem to think is your ID).
If that does not produce the output you expect, add some Serial.print() statements to figure out why not.
halo guys, I'm working with fingerprint and, it's working with the code that I found in internet, and I saw this forum talking about changing the ID# into the name
it's working as well,
but I can't adding another ID# and name, it's only display one name with many ID# and name in Global variable
please help me to solve it
thanks for your time