I'm new to arduino and I'm sure this is a very basic issue, however here I'm trying to make a door lock that will first ask for a passcode, then to scan a fingerprint, and lastly open the door. Currently under void loop() I have a { with a } directly under this. For some reason, without having this closed bracket right after I'll get an error saying that "getFingerprintID was not declared in this scope." However when I do put the closed bracket there I get errors on all of the if(!#) loops saying "expected unqualified-id before 'if'" For the fingerprint reading part of the code, I'm using the code from the adafruit fingerprint library's "fingerprint" example because I don't fully understand how it works. If someone could give me some insight on why I may be getting these errors and how I might be able to fix them that would be great. (To add onto this the number pad section of the code works perfectly fine, it's only when I add the fingerprint-reading section that I have issues.)
#include <Adafruit_Fingerprint.h>
// Include Wire Library for I2C
#include <Wire.h>
// Include NewLiquidCrystal Library for I2C
#include <LiquidCrystal_I2C.h>
// Define LCD pinout
const int en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;
// Define I2C Address - change if reqiuired
const int i2c_addr = 0x27;
LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
SoftwareSerial mySerial(2, 3);
#else
#define mySerial Serial1
#endif
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
String input;
void setup() {
Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("\n\nAdafruit finger detect test");
// set the data rate for the sensor serial port
finger.begin(57600);
finger.getParameters();
finger.getTemplateCount();
if (finger.templateCount == 0) {
Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
}
else {
Serial.println("Waiting for valid finger...");
Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
}
Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("\n\nAdafruit finger detect test");
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
lcd.begin(16, 2);
finger.begin(57600);
lcd.setCursor(0, 0);
lcd.write("Enter Passcode:");
lcd.setCursor(0, 1);
lcd.write(">");
}
void loop() // run over and over again
{
}
int star = digitalRead(2);
int seven = digitalRead(3);
int four = digitalRead(4);
int one = digitalRead(5);
int zero = digitalRead(6);
int eight = digitalRead(7);
int five = digitalRead(8);
int two = digitalRead(9);
int pound = digitalRead(10);
int nine = digitalRead(11);
int six = digitalRead(12);
int three = digitalRead(13);
if (!seven)
{
lcd.print("7");
input += "7";
delay(300);
}
if (!four)
{
lcd.print("4");
input += "4";
delay(300);
}
if (!one)
{
lcd.print("1");
input += "1";
delay(300);
}
if (!zero)
{
lcd.print("0");
input += "0";
delay(300);
}
if (!eight)
{
lcd.print("8");
input += "8";
delay(300);
}
if (!five)
{
lcd.print("5");
input += "5";
delay(300);
}
if (!two)
{
lcd.print("2");
input += "2";
delay(300);
}
if (!nine)
{
lcd.print("9");
input += "9";
delay(300);
}
if (!six)
{
lcd.print("6");
input += "6";
delay(300);
}
if (!three)
{
lcd.print("3");
input += "3";
delay(300);
}
if (!pound)
{
if (input == ("1111"))
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Accepted.");
delay(1500);
lcd.clear();
lcd.print("Scanning...");
getFingerprintID();
delay(100);
}
uint8_t getFingerprintID() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
case FINGERPRINT_NOFINGER:
Serial.println("No finger detected");
// OK success!
p = finger.image2Tz();
// OK converted!
p = finger.fingerSearch();
if (p == FINGERPRINT_OK) {
Serial.println("Found a print match!");
if (scan == 1) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Access Granted.");
lcd.setCursor(0, 1);
lcd.print("Welcome, ...");
delay(15000);
lcd.clear();
lcd.print("Timed Out.");
delay(1500);
lcd.clear();
lcd.print("Enter Passcode:");
lcd.setCursor(0, 1);
lcd.print(">");
}
input = "";
delay(10000);
scan = 0;
lcd.clear();
lcd.print("Timed Out.");
delay(1500);
lcd.clear();
lcd.print("Enter Passcode:");
lcd.setCursor(0, 1);
lcd.print(">");
}
else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Incorrect.");
delay(1000);
lcd.clear();
lcd.print("Enter Passcode:");
lcd.setCursor(0, 1);
lcd.print(">");
input = "";
}
}
}
}