Hi im having this type of problem keep on pooping up
PIGGYBANK_CODE:109:1: error: 'lcd' does not name a type
lcd.print("Welcome"); { //Printing a message for the recognized template
^~~
PIGGYBANK_CODE:109:23: error: expected unqualified-id before '{' token
lcd.print("Welcome"); { //Printing a message for the recognized template
^
exit status 1
'lcd' does not name a type
here is the full code
#include <Adafruit_Fingerprint.h> //Libraries needed
#include <SoftwareSerial.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <EEPROM.h>
#define I2C_ADDR 0x27 //LCD i2c stuff
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define coinSlot 6
int coinValue = 0;
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
int in2 = 4;
int But1 = 8; // In order to add a push button I got the 5v from the pin 8 instead of "5v" arduino pin
int But2 = 9;
String Names[] = { "RAVEN", "Surtr", "Tech",}; //Those are the names affected to the fingertemplates IDs
//The first on which is Names[0] : Yassine has the ID 1 in the fingerprint sensor
SoftwareSerial mySerial(2, 3); //Fingerprint sensor wiring RX 3, TX 2
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin); //LCD declaring
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); //Fingerprint sensor declaring
void setup()
{
pinMode(in2, OUTPUT);
digitalWrite(in2, HIGH);
digitalWrite(But1, LOW);
pinMode(coinSlot, INPUT_PULLUP);
Serial.begin(9600);
finger.begin(57600);
lcd.begin (16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);
lcd.home();
lcd.write(EEPROM.read(5));
finger.getTemplateCount(); //Counts the number of templates stored in the sensor flash memory
delay(2000);
introScreen();
}
void loop()
{
int result = getFingerprintIDez(); //This function keeps looping and waiting for a fingerprint to be put on the sensor
OpenDoor();
introScreen();
while (!coinInserted) {
coinSlotSignal = digitalRead(coinSlot);
if (coinSlotSignal < 1) {
coinCount += 1;
coinInserted = true;
EEPROM.write(0, coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0, 0);
lcd.print("TOTAL:");
lcd.setCursor(0, 1);
lcd.print(coinCount);
}
}
while (coinInserted) {
coinSlotSignal = digitalRead(coinSlot);
if (coinSlotSignal > 0) {
coinInserted = false;
}
}
if (coinCount >= requiredCoins) {
delay(1500);
}
}
void introScreen()
{
lcd.clear();
lcd.print("Place finger");
}
//Main function taken from the "fingerprint" example and modified
//Only the modifications are commented
int getFingerprintIDez() {
uint8_t p = finger.getImage(); //Image scanning
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz(); //Converting
if (p != FINGERPRINT_OK) return -1;
lcd.clear(); //And here we write a message or take an action for the denied template
p = finger.fingerFastSearch(); //Looking for matches in the internal memory
if (p != FINGERPRINT_OK) { //if the searching fails it means that the template isn't registered
lcd.print("Access denied");
delay(2000);
introScreen();
return -1;
}
}
//If we found a match we proceed in the function
lcd.print("Welcome"); { //Printing a message for the recognized template
lcd.setCursor(2, 1);
lcd.print(Names[finger.fingerID - 1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
return finger.fingerID;
}
/*The two following functions depends on your locking system
mine has a DC motor that should turn in both ways for opening and closing
that's why I'm using H bridge, you could have a solenoid with a transistor
then you'll need only opening sequence but controlling the transistor
as the closing is spring loaded...
*/
void OpenDoor()
{
digitalWrite(in2, LOW); // turn on motor
delay(5000);
digitalWrite(in2, HIGH); // turn off motor
}
hoping someone can guide me close to finish my project
its showing more errors sir after removing the bracket
C:\Users\asus\Documents\MARVE THESIS\THESIS1\PROJECT2021\PIGGYBANK_CODE\PIGGYBANK_CODE.ino: In function 'void loop()':
PIGGYBANK_CODE:55:3: error: 'OpenDoor' was not declared in this scope
OpenDoor();
^~~~~~~~
C:\Users\asus\Documents\MARVE THESIS\THESIS1\PROJECT2021\PIGGYBANK_CODE\PIGGYBANK_CODE.ino:55:3: note: suggested alternative: 'perror'
OpenDoor();
^~~~~~~~
perror
C:\Users\asus\Documents\MARVE THESIS\THESIS1\PROJECT2021\PIGGYBANK_CODE\PIGGYBANK_CODE.ino: At global scope:
PIGGYBANK_CODE:108:1: error: 'lcd' does not name a type
lcd.print("Welcome"); //Printing a message for the recognized template
^~~
PIGGYBANK_CODE:109:3: error: 'lcd' does not name a type
lcd.setCursor(2, 1);
^~~
PIGGYBANK_CODE:110:3: error: 'lcd' does not name a type
lcd.print(Names[finger.fingerID - 1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
^~~
PIGGYBANK_CODE:111:3: error: expected unqualified-id before 'return'
return finger.fingerID;
^~~~~~
PIGGYBANK_CODE:112:1: error: expected declaration before '}' token
}
^
exit status 1
'OpenDoor' was not declared in this scope
lcd.print("Welcome"); //Printing a message for the recognized template
lcd.setCursor(2, 1);
lcd.print(Names[finger.fingerID - 1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
return finger.fingerID;
}
}
this was the error code left
C:\Users\asus\Documents\MARVE THESIS\THESIS1\PROJECT2021\PIGGYBANK_CODE\PIGGYBANK_CODE.ino: In function 'void loop()':
PIGGYBANK_CODE:55:3: error: 'OpenDoor' was not declared in this scope
OpenDoor();
^~~~~~~~
C:\Users\asus\Documents\MARVE THESIS\THESIS1\PROJECT2021\PIGGYBANK_CODE\PIGGYBANK_CODE.ino:55:3: note: suggested alternative: 'perror'
OpenDoor();
^~~~~~~~
perror
C:\Users\asus\Documents\MARVE THESIS\THESIS1\PROJECT2021\PIGGYBANK_CODE\PIGGYBANK_CODE.ino: At global scope:
PIGGYBANK_CODE:112:1: error: expected declaration before '}' token
}
^
exit status 1
'OpenDoor' was not declared in this scope
please sir can you check my code if I'm not missing anything here?
this was not having any error code anymore.
#include <Adafruit_Fingerprint.h> //Libraries needed
#include <SoftwareSerial.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <EEPROM.h>
#define I2C_ADDR 0x27 //LCD i2c stuff
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define coinSlot 6
int coinValue = 0;
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
int in2 = 4;
int But1 = 8; // In order to add a push button I got the 5v from the pin 8 instead of "5v" arduino pin
int But2 = 9;
String Names[] = { "RAVEN", "Surtr", "Tech",}; //Those are the names affected to the fingertemplates IDs
//The first on which is Names[0] : Yassine has the ID 1 in the fingerprint sensor
SoftwareSerial mySerial(2, 3); //Fingerprint sensor wiring RX 3, TX 2
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin); //LCD declaring
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); //Fingerprint sensor declaring
void setup()
{
pinMode(in2, OUTPUT);
digitalWrite(in2, HIGH);
digitalWrite(But1, LOW);
pinMode(coinSlot, INPUT_PULLUP);
Serial.begin(9600);
finger.begin(57600);
lcd.begin (16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);
lcd.home();
lcd.write(EEPROM.read(5));
finger.getTemplateCount(); //Counts the number of templates stored in the sensor flash memory
delay(2000);
introScreen();
}
void loop()
{
int result = getFingerprintIDez(); //This function keeps looping and waiting for a fingerprint to be put on the sensor
OpenDoor();
introScreen();
while (!coinInserted) {
coinSlotSignal = digitalRead(coinSlot);
if (coinSlotSignal < 1) {
coinCount += 1;
coinInserted = true;
EEPROM.write(0, coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0, 0);
lcd.print("TOTAL:");
lcd.setCursor(0, 1);
lcd.print(coinCount);
}
}
while (coinInserted) {
coinSlotSignal = digitalRead(coinSlot);
if (coinSlotSignal > 0) {
coinInserted = false;
}
}
if (coinCount >= requiredCoins) {
delay(1500);
}
}
void introScreen()
{
lcd.clear();
lcd.print("Place finger");
}
//Main function taken from the "fingerprint" example and modified
//Only the modifications are commented
int getFingerprintIDez() {
uint8_t p = finger.getImage(); //Image scanning
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz(); //Converting
if (p != FINGERPRINT_OK) return -1;
lcd.clear(); //And here we write a message or take an action for the denied template
p = finger.fingerFastSearch(); //Looking for matches in the internal memory
if (p != FINGERPRINT_OK) { //if the searching fails it means that the template isn't registered
lcd.print("Access denied");
delay(2000);
introScreen();
return -1;
}
//If we found a match we proceed in the function
lcd.print("Welcome"); //Printing a message for the recognized template
lcd.setCursor(2, 1);
lcd.print(Names[finger.fingerID - 1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
return finger.fingerID;
}
/*The two following functions depends on your locking system
mine has a DC motor that should turn in both ways for opening and closing
that's why I'm using H bridge, you could have a solenoid with a transistor
then you'll need only opening sequence but controlling the transistor
as the closing is spring loaded...
*/
void OpenDoor()
{
digitalWrite(in2, LOW); // turn on motor
delay(5000);
digitalWrite(in2, HIGH); // turn off motor
}
When I run the good it shows in the Lcd was showing "Total:" but then If I insert the coin it will detect 1 but when I try the second one it respond it won't add up the value.
Then I Tried this code finger print wont detect finger print (not light up )
#include <Adafruit_Fingerprint.h> //Libraries needed
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#define coinSlot 9 // different pin!!! untested!!!
#define I2C_ADDR 0x27 //LCD i2c stuff
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int in2 = 4;
int But1=8; // In order to add a push button I got the 5v from the pin 8 instead of "5v" arduino pin
int But2=9;
String Names[] = { "RAVEN", "Surtr", "Tech",}; //Those are the names affected to the fingertemplates IDs
//The first on which is Names[0] : Yassine has the ID 1 in the fingerprint sensor
SoftwareSerial mySerial(2, 3); //Fingerprint sensor wiring RX 3, TX 2
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); //LCD declaring
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); //Fingerprint sensor declaring
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
void setup()
{
pinMode(in2, OUTPUT);
digitalWrite(in2, HIGH);
pinMode(But1, OUTPUT); //Push button stuff, I made the pin 8 permanent LOW level
digitalWrite(But1,LOW);
pinMode(But2,INPUT_PULLUP); //And I read the button state on pin 9
pinMode(coinSlot, INPUT_PULLUP);
lcd.write(EEPROM.read(5));
Serial.begin(9600); //Serial begin incase you need to see something on the serial monitor
finger.begin(57600); //Sensor baude rate
lcd.begin (16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home();
finger.getTemplateCount(); //Counts the number of templates stored in the sensor flash memory
delay(2000);
}
void loop()
{
int result = getFingerprintIDez(); //This function keeps looping and waiting for a fingerprint to be put on the sensor
//delay(50);
bool Button1=digitalRead(But2); //Reading the state of the pushbutton
if(Button1==LOW or result >= 0){
//If the button is pressed it opens the doorlock as the button is meant to be inside
OpenDoor();
}
// Coinslot
while(!coinInserted){
coinSlotSignal = digitalRead(coinSlot);
if(coinSlotSignal < 1) {
coinCount += 1;
coinInserted = true;
EEPROM.write(0,coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0,0);
lcd.print("TOTAL:");
lcd.setCursor(0,1);
lcd.print(coinCount);
} // if
} // while
while(coinInserted) {
coinSlotSignal = digitalRead(coinSlot);
if(coinSlotSignal >0) {
coinInserted = false;
}
}
if(coinCount >= requiredCoins) {
delay(1500);
}
}
//Main function taken from the "fingerprint" example and modified
//Only the modifications are commented
int getFingerprintIDez() {
uint8_t p = finger.getImage(); //Image scanning
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz(); //Converting
if (p != FINGERPRINT_OK) return -1;
lcd.clear(); //And here we write a message or take an action for the denied template
p = finger.fingerFastSearch(); //Looking for matches in the internal memory
if (p != FINGERPRINT_OK){ //if the searching fails it means that the template isn't registered
lcd.print("Access denied");
delay(2000);
return -1;
}
//If we found a match we proceed in the function
lcd.print("Welcome"); //Printing a message for the recognized template
lcd.setCursor(2,1);
lcd.print(Names[finger.fingerID-1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
return finger.fingerID;
}
/*The two following functions depends on your locking system
*mine has a DC motor that should turn in both ways for opening and closing
*that's why I'm using H bridge, you could have a solenoid with a transistor
*then you'll need only opening sequence but controlling the transistor
*as the closing is spring loaded...
*/
void OpenDoor(){
digitalWrite(in2, LOW); // turn on motor
delay(5000);
digitalWrite(in2, HIGH); // turn off motor
}
I tried to remove the button function because it was not used in the project ..
Please check it sir, if I have error or I've missplace some code
#include <Adafruit_Fingerprint.h> //Libraries needed
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#define coinSlot 9 // different pin!!! untested!!!
#define I2C_ADDR 0x27 //LCD i2c stuff
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int in2 = 4;
String Names[] = { "RAVEN", "Surtr", "Tech",}; //Those are the names affected to the fingertemplates IDs
//The first on which is Names[0] : Yassine has the ID 1 in the fingerprint sensor
SoftwareSerial mySerial(2, 3); //Fingerprint sensor wiring RX 3, TX 2
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); //LCD declaring
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); //Fingerprint sensor declaring
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
void setup()
{
pinMode(in2, OUTPUT);
digitalWrite(in2, HIGH);
pinMode(coinSlot, INPUT_PULLUP);
lcd.write(EEPROM.read(5));
Serial.begin(9600); //Serial begin incase you need to see something on the serial monitor
finger.begin(57600); //Sensor baude rate
lcd.begin (16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home();
finger.getTemplateCount(); //Counts the number of templates stored in the sensor flash memory
delay(2000);
}
void loop()
{
int result = getFingerprintIDez(); //This function keeps looping and waiting for a fingerprint to be put on the sensor
OpenDoor();
// Coinslot
while(!coinInserted){
coinSlotSignal = digitalRead(coinSlot);
if(coinSlotSignal < 1) {
coinCount += 1;
coinInserted = true;
EEPROM.write(0,coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0,0);
lcd.print("TOTAL:");
lcd.setCursor(0,1);
lcd.print(coinCount);
} // if
} // while
while(coinInserted) {
coinSlotSignal = digitalRead(coinSlot);
if(coinSlotSignal >0) {
coinInserted = false;
}
}
if(coinCount >= requiredCoins) {
delay(1500);
}
}
//Main function taken from the "fingerprint" example and modified
//Only the modifications are commented
int getFingerprintIDez() {
uint8_t p = finger.getImage(); //Image scanning
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz(); //Converting
if (p != FINGERPRINT_OK) return -1;
lcd.clear(); //And here we write a message or take an action for the denied template
p = finger.fingerFastSearch(); //Looking for matches in the internal memory
if (p != FINGERPRINT_OK){ //if the searching fails it means that the template isn't registered
lcd.print("Access denied");
delay(2000);
return -1;
}
//If we found a match we proceed in the function
lcd.print("Welcome"); //Printing a message for the recognized template
lcd.setCursor(2,1);
lcd.print(Names[finger.fingerID-1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
return finger.fingerID;
}
/*The two following functions depends on your locking system
*mine has a DC motor that should turn in both ways for opening and closing
*that's why I'm using H bridge, you could have a solenoid with a transistor
*then you'll need only opening sequence but controlling the transistor
*as the closing is spring loaded...
*/
void OpenDoor(){
digitalWrite(in2, LOW); // turn on motor
delay(5000);
digitalWrite(in2, HIGH); // turn off motor
}
But still fingerprint wont lightup if I try to enter finger
Every Adafruit_Fingerprint.h library example has this simple test at the beginning. What do you see when you add this to your code?
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1);
}
You are using software serial, and I would take the baud rate down to 9600, and bring it up when things are working. Higher baud rates can be less reliable.
#include <Adafruit_Fingerprint.h> //Libraries needed
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#define coinSlot 9 // different pin!!! untested!!!
#define I2C_ADDR 0x27 //LCD i2c stuff
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int in2 = 4;
String Names[] = { "RAVEN", "Surtr", "Tech",}; //Those are the names affected to the fingertemplates IDs
//The first on which is Names[0] : Yassine has the ID 1 in the fingerprint sensor
SoftwareSerial mySerial(2, 3); //Fingerprint sensor wiring RX 3, TX 2
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); //LCD declaring
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); //Fingerprint sensor declaring
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
void setup()
{
pinMode(in2, OUTPUT);
digitalWrite(in2, HIGH);
pinMode(coinSlot, INPUT_PULLUP);
lcd.write(EEPROM.read(5));
Serial.begin(9600); //Serial begin incase you need to see something on the serial monitor
finger.begin(9600);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1);
}
lcd.begin (16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home();
finger.getTemplateCount(); //Counts the number of templates stored in the sensor flash memory
delay(2000);
}
void loop()
{
int result = getFingerprintIDez(); //This function keeps looping and waiting for a fingerprint to be put on the sensor
OpenDoor();
// Coinslot
while(!coinInserted){
coinSlotSignal = digitalRead(coinSlot);
if(coinSlotSignal < 1) {
coinCount += 1;
coinInserted = true;
EEPROM.write(0,coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0,0);
lcd.print("TOTAL:");
lcd.setCursor(0,1);
lcd.print(coinCount);
} // if
} // while
while(coinInserted) {
coinSlotSignal = digitalRead(coinSlot);
if(coinSlotSignal >0) {
coinInserted = false;
}
}
if(coinCount >= requiredCoins) {
delay(1500);
}
}
//Main function taken from the "fingerprint" example and modified
//Only the modifications are commented
int getFingerprintIDez() {
uint8_t p = finger.getImage(); //Image scanning
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz(); //Converting
if (p != FINGERPRINT_OK) return -1;
lcd.clear(); //And here we write a message or take an action for the denied template
p = finger.fingerFastSearch(); //Looking for matches in the internal memory
if (p != FINGERPRINT_OK){ //if the searching fails it means that the template isn't registered
lcd.print("Access denied");
delay(2000);
return -1;
}
//If we found a match we proceed in the function
lcd.print("Welcome"); //Printing a message for the recognized template
lcd.setCursor(2,1);
lcd.print(Names[finger.fingerID-1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
return finger.fingerID;
}
void OpenDoor(){
digitalWrite(in2, LOW); // turn on motor
delay(5000);
digitalWrite(in2, HIGH); // turn off motor
}
but Having trouble on how to make my coin detect faster because sometimes it cant detect after continues insert of coins
here is the proper working code sir
#include <Adafruit_Fingerprint.h> //Libraries needed
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#define coinSlot 9 // different pin!!! untested!!!
#define I2C_ADDR 0x27 //LCD i2c stuff
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int in2 = 4;
String Names[] = { "RAVEN", "Surtr", "Tech",}; //Those are the names affected to the fingertemplates IDs
//The first on which is Names[0] : "" has the ID 1 in the fingerprint sensor
SoftwareSerial mySerial(2, 3); //Fingerprint sensor wiring RX 3, TX 2
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin); //LCD declaring
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); //Fingerprint sensor declaring
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
void setup()
{
pinMode(in2, OUTPUT);
digitalWrite(in2, HIGH);
pinMode(coinSlot, INPUT_PULLUP);
lcd.write(EEPROM.read(5));
Serial.begin(9600); //Serial begin incase you need to see something on the serial monitor
finger.begin(57600); //Sensor baude rate
lcd.begin (16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);
lcd.home();
finger.getTemplateCount(); //Counts the number of templates stored in the sensor flash memory
delay(2000);
}
void loop()
{
int FingerPrintResult = getFingerprintIDez();
if (FingerPrintResult != -1) { //This function keeps looping and waiting for a fingerprint to be put on the sensor
OpenDoor();
}
else
// only check for coins to be inserted if we're not opening the door
coinSlotSignal = digitalRead(coinSlot);
if (coinSlotSignal < 1) {
coinCount++;
EEPROM.write(0, coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0, 0);
lcd.print("TOTAL:");
lcd.setCursor(0, 1);
lcd.print(coinCount);
delay(1000);
// add a little delay, since the coinslot may show a signal longer
}
else {
lcd.clear();
}
}
//Only the modifications are commented
int getFingerprintIDez() {
uint8_t p = finger.getImage(); //Image scanning
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz(); //Converting
if (p != FINGERPRINT_OK) return -1;
lcd.clear(); //And here we write a message or take an action for the denied template
p = finger.fingerFastSearch(); //Looking for matches in the internal memory
if (p != FINGERPRINT_OK) { //if the searching fails it means that the template isn't registered
lcd.print("Access denied");
delay(2000);
return -1;
}
//If we found a match we proceed in the function
lcd.print("Welcome"); //Printing a message for the recognized template
lcd.setCursor(2, 1);
lcd.print(Names[finger.fingerID - 1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from "1" but the array from "0"
return finger.fingerID;
}
void OpenDoor() {
digitalWrite(in2, LOW); // turn on motor
delay(5000);
digitalWrite(in2, HIGH); // turn off motor
}
The device is like a secured buggy bank it will unlock in 5 seconds then lock again. The Lcd must display if I'll insert the coin it must show "Total : "
after that if I tried to enter my finger it will active the Lcdclear then displays "Welcome Raven" and unlock the solenoid lock for 5 seconds then goes lock again