hi i think i've got it... im trying to call the fingerprint sensor after entering password.
the problem is juz that after i break the password using * key, the sensor illuminates <1.0sec.
how do i get it illuminate in a longer time, without pressing the * button many times.
here;s my new code
- Code: Select all
#include <Password.h>
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(40, 42, 44, 46, 48, 50, 52);
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif
Password password = Password( "C141516" );
const byte ROWS = 4; // Four rows
const byte COLS = 4; // columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','4','7','*'},
{'2','5','8','0'},
{'3','6','9','#'},
{'A','B','C','D'}
};
byte rowPins[ROWS] = {31,33,35,37}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23,25,27,29}; //connect to the column pinouts of the keypad
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int alarm_var = 0;
int getFingerprintIDez();
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(12, 13);
#else
NewSoftSerial mySerial(12, 13);
#endif
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
/*SETUP****************************************************************************************/
void setup()
{
lcd.begin(16, 2);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
lcd.clear();
lcd.print("Password:");
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
finger.begin(57600);
//digitalWrite(11,HIGH);
}
/************************************************************************************/
void loop()
{
//digitalWrite(11,HIGH);
//digitalWrite(9,LOW);
if (digitalRead(11)==LOW)
{
digitalWrite(9,HIGH);
lcd.clear();
lcd.print("INTRUDER!!");
delay(1000000);
digitalWrite(9,LOW);
}
if(alarm_var < 3)
{
keypad.getKey();
}
}
/************************************************************************/
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
//lcd.print("");
lcd.print(eKey);
switch (eKey){
case '*': checkPassword(); break;
case '#': password.reset(); break;
default: password.append(eKey);
}
}
}
void checkPassword(){
if (password.evaluate()){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Success!");
lcd.setCursor(0,1);
lcd.print("Now scan finger ");
getFingerprintIDez();
//delay(1000);
}
else{
alarm_var = alarm_var + 1;
//for (i=0; i>3; i++);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Wrong");
if (alarm_var >= 3)
{
lcd.setCursor(0,0);
lcd.print("Wrong 3 times");
lcd.setCursor(0,1);
lcd.print("Alarm Activated");
digitalWrite(9,HIGH);
//alarm_var = 0;
}
else
{
delay(1000);
lcd.clear();
lcd.print("Password:");
password.reset();
}
}
}
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(11,LOW); // switch OFF red LED
digitalWrite(10, HIGH); //switch ON green LED
delay(1000);
digitalWrite(10,LOW);// switch OFF green LED
digitalWrite(9,HIGH); // switch ON alarm
delay(100);
digitalWrite(9,LOW);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Match ID #");
lcd.print(finger.fingerID);
lcd.setCursor(0,1);
lcd.print("Accepted ");
return finger.fingerID;
//delay(100);
}