Thanks for the fast reply sir
Â
I tried to run the code but It was just showing the "place finger" then if I tried to insert coin it shows "TOTAL:finger" second lower line the total amount of the coin, Then the fingerprint scanner wont work also (no light if it try to put my finger)
Â
what if you delete the statement of the place finger?
and the fingerprint scanner was not working also
This code I tried it will show the TOTAL: and value of coins inserted in the lower line
But the finger print was not working
Then after running this new code It will autoamticaly shows 1 value even i dint inserted coin
 The project will goes like this
If the Arduino runs it will show total amount of coins
then if I tried to enter my finger fingerprint it will unlock the solenoid showing "Welcome "name"
then goes back to how much coin was inserted again
Â
is this possible ? if not maybe some suggestion?
#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
}