@hans why those if I tried to add fingerprint the LCD dislay will display the "WELCOME "name" " but it wont dissaper at all
I already figured out it sir , your right I don't need the pinchangeint. I jsut nned the attachedint so what I did is I change my serialsoftware pins to ( 0, 2) then used the int pin of 3 in the UNO pins.
after that I've noticed that the coins was adding 2 values evrytime the coin was detected so I just remove the line of code here
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
{
coinSlotSignal = digitalRead(coinSlot);
if (coinInserted) {
coinInserted = false;
coinCount++;
EEPROM.write(0, coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0, 0);
lcd.print("TOTAL:");
lcd.setCursor(0, 1);
lcd.print(coinCount);
}
}
}
to this
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
{
coinSlotSignal = digitalRead(coinSlot);
if (coinInserted) {
coinInserted = false;
EEPROM.write(0, coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0, 0);
lcd.print("TOTAL:");
lcd.setCursor(0, 1);
lcd.print(coinCount);
}
}
}
after that I've fix some codes then this is the full code now
#include <Adafruit_Fingerprint.h> //Libraries needed
#include <SoftwareSerial.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#define coinSlot 3 // coinslot 5v to 0v if coin passes on the sensor
#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 relayPin = 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(0, 2); //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
volatile int coinCount = 0;
int requiredCoins = 1;
boolean coinInserted = false;
int coinSlotSignal;
void setup()
{
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH);
pinMode(coinSlot, INPUT_PULLUP);
lcd.write(EEPROM.read(5));
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(3), coinInterrupt, FALLING);
Serial.print(coinSlot);
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 coinInterrupt() {
coinCount++ ;
coinInserted = true;
}
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
{
coinSlotSignal = digitalRead(coinSlot);
if (coinInserted) {
coinInserted = false;
EEPROM.write(0, coinCount);
Serial.println(EEPROM.read(0));
lcd.setCursor(0, 0);
lcd.print("TOTAL:");
lcd.setCursor(0, 1);
lcd.print(coinCount);
}
}
}
//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(relayPin, LOW); // turn on solenoidlock
delay(5000);
digitalWrite(relayPin, HIGH); // turn off solenoidlock
}
thanks for advising that I might need to try the coinslot interrupt out from my full code then It was Cleary seen it.
but 1 thing how can I solve the display of the welcome it wont go away even I tried to add coin it will missed up the text