Hi there! I'm trying to get it so that this button can only be pressed when a valid fingerprint is scanned. Right now, the code compiles and works up to the point of the button being able to be pressed. When the fingerprint is accepted, it changes to the "PASSWORDS" section, but the button no longer cycles through the passwords. What can I do to fix this?
My code is here:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <Adafruit_Fingerprint.h>
SoftwareSerial mySerial(7, 6);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
int fingerprintID = 0;
#include <SoftwareSerial.h>
const byte buttonPin1 = 10;
int Counter = 0;
boolean btnState1 = LOW;
boolean lastState1 = LOW;
void setup()
{
Serial.begin(9600);
finger.begin(57600);
lcd.begin(16, 2);
lcd.print("LOCKED.");
lcd.setCursor(0,3);
lcd.print("SCAN FINGERPRINT");
pinMode(buttonPin1, INPUT);
}
void loop()
{
btnState1 = digitalRead(buttonPin1);
fingerprintID = getFingerprintID();
delay(50);
if(fingerprintID == 1)
{
Counter++;
lcd.clear();
lcd.print("PASSWORDS");
if (btnState1 != lastState1)
{
if (btnState1 == HIGH)
{
Counter++;
lcd.clear();
if (Counter > 4)
{
Counter = 1;
}
Serial.println(Counter);
switch (Counter)
{
case 1:
lcd.print("FaceBook");
lcd.setCursor(0,3);
lcd.print("&$lPBASag0525");
break;
case 2:
lcd.print("Email");
lcd.setCursor(0,3);
lcd.print("&duYzQ7lR1Fdf7FK");
break;
case 3:
lcd.print("Banking");
lcd.setCursor(0,3);
lcd.print("B9k%hA8z$o4RC$nD");
break;
case 4:
lcd.print("Antivirus");
lcd.setCursor(0,3);
lcd.print("^6h2w@7xJ0wGG*z");
break;
}
}
lastState1 = btnState1;
}
}
}
int getFingerprintID() {
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!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
return finger.fingerID;
}