Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!




Windows - Arduino S...
 
Share:
Notifications
Clear all

Windows - Arduino Solenoid Lock using FingerPrint with CoinCounter

Page 1 / 5

(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

Hi good day to all I'm new here hoping someone can give some advice how can I get the 2 codes working at 1 Arduino code.

My project is all about like a secured vault but it will display it the total pcs of coins inside the vault.

I have 2 codes is from the finger print code

Then the one is form coin slot using INPUT_PULLUP code.

 

SCHEMATIC

 

CODE FOR FINGERPRINT

#include <Adafruit_Fingerprint.h>    //Libraries needed
#include <SoftwareSerial.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.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

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);
  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
 
  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);
  introScreen();
}

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();
    introScreen();
  }
}

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
}

 

 

COIN SLOT CODE its working when I upload it to Arduino, but having hardtime how to sink it to the fingerprint code

 

 

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#define coinSlot 6


LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified module

int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;


void setup() {
  Serial.begin(9600); 
 pinMode(coinSlot, INPUT_PULLUP);

 lcd.setBacklightPin(3,POSITIVE);
 lcd.setBacklight(LOW); // You can turn the backlight off by setting it to LOW instead of HIGH
 lcd.begin(16, 2);
lcd.write(EEPROM.read(5));
}

void loop() {
  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);
}

ReplyQuote
Topic Tags
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2004
 

Two issues I ran into while giving it a try (unable to test - I do not have this hardware).

1) What LCD.h library did you use? (I wasn't able to find the one you seem to be using)

2) One of the pins you're using for the LCD is conflicting with the one you're using for the Coinslot (pin 6).

You'll need to select a different pin for that (probably easiest to select a different one for the Coinslot - arbitrarily picked pin 9, and I'm not sure this will work).

 

VERY crudely thrown together and probably still with errors (cannot compile since I do not seem to have the correct LCD.h):

#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);
  introScreen();
}

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();
    introScreen();
  }


  // 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);
  }
}

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
}

ReplyQuote
(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

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
}

ReplyQuote
(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

I tried also remove the button codes that was not necessary also the introSCREEN

 

#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
}

ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2004
 

It is quite difficult, without the proper hardware, to determine what is going on, or what the proper steps are in the loop.

So as far as I understand we have these scenario's:

1. Coin is inserted
2. No coin is inserted
3. Finger print is read to open door

However, when looking at the loop, I see two while() loops:

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);
  }
}

 

These while() loops may keep looping and prevent responsive actions when one of the other scenario's takes place.
Initially I'd replace them with if(). On top of that initialization of "coinInserted" is a little confusing.

I also see the fingerprint reading and without any condition checking a call to OpenDoor(). This doesn't seem right either.

So maybe it is a good idea to start with modifying with the basics first.

The fingerprint reading:

int FingerPrintResult = getFingerprintIDez();
if (FingerPrintResult!=-1) { 
    OpenDoor();
}
else
{ 
   // only check for coins to be inserted
   // if we're not opening the door
}

 

Next, if we're not opening the door, we can check if a coin was inserted.

int FingerPrintResult = getFingerprintIDez();
if (FingerPrintResult!=-1) { 
    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   
  }
}

 

I assume coinSlotSignal will be greater than 1 when a coin was inserted. (??)
Not sure what the purpose of "requiredCoins" is going to be though ...

It is always best in cases like this to make each piece working, one at a time.

I hope this helps. As I said: I cannot test this myself.


ReplyQuote


(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

@hans I tried the code 

 

1.fingerprint working it's sending signal in pin 4 

2. Problem with the TOTAL the welcome wont remove and also the name

3. It was also takes time to detect the coin

 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2004
 

I suspect the fingerprint reading takes a little more time than expected?
Or maybe remove or reduce the delay(1000) when detecting the coin.

If you want the text to be removed when there is no coin then you could add a clear screen (not sure what the command would be for LCD.h) like sio:

   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 {
    // clear LCD screen here
    // or display a message that it's waiting?
    lcd.Clear(); // not sure if this is the right function
  }

ReplyQuote
(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

@hans I tried to add 800 delay but its like not detecting the coin adding it to 1500 its not like detecting coin also what delay number should I try?


ReplyQuote
(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  
Posted by: @hans

I suspect the fingerprint reading takes a little more time than expected?
Or maybe remove or reduce the delay(1000) when detecting the coin.

If you want the text to be removed when there is no coin then you could add a clear screen (not sure what the command would be for LCD.h) like sio:

   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 {
    // clear LCD screen here
    // or display a message that it's waiting?
    lcd.Clear(); // not sure if this is the right function
  }

The lcd.clear was correct sir it was changing the display I tried to enter the dingerprint but it will just stay 2 second then screen black insert coin then blank again


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2004
 
Posted by: @kalilinux25

I tried to add 800 delay but its like not detecting the coin adding it to 1500 its not like detecting coin also what delay number should I try?

You can always try 😊 

The downside of the delay is that the Arduino will not respond to anything during the delay time. So inserting a coin of pressing the fingerprint-reader won't do anything for that second or so.

However, a small delay may be needed for the coin slot. I'm not sure how long it will show "contact" when a coin goes in.

You could of course just remove the delay and see what happens.


ReplyQuote


(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

@hans also its not capturing the coins if I just manually point the coin to the coin sensor its getting the exact value of coins.. 


ReplyQuote
(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

@hans I tried to remove the delay It takes 3 coin counts then the 4th cant detect after 3 seconds it can detect again. I also tried to hook up the coin slot with 5v external power(maybe the arduino volt was not enough) but same no cahnges. 


ReplyQuote
(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

@hans is this the proper coid sir in the void loop or im missing a bracket?

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();
  }
}

ReplyQuote
(@kalilinux25)
Eminent Member
Joined: 4 months ago
Posts: 41
Topic starter  

if I also tried to add a { here in the else condition 

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
{

 

it shows error like

 

C:\Users\asus\Documents\MARVE THESIS\THESIS_2\THESIS_2.ino: In function 'void loop()':
THESIS_2 error: 'getFingerprintIDez' was not declared in this scope
   int FingerPrintResult = getFingerprintIDez();
                           ^~~~~~~~~~~~~~~~~~
THESIS_2 error: 'OpenDoor' was not declared in this scope
     OpenDoor();
     ^~~~~~~~
C:\Users\asus\Documents\MARVE THESIS\THESIS_2\THESIS_2.ino note: suggested alternative: 'perror'
     OpenDoor();
     ^~~~~~~~
     perror
THESIS_2 error: a function-definition is not allowed here before '{' token
 int getFingerprintIDez() {
                          ^
THESIS_2 error: a function-definition is not allowed here before '{' token
 void OpenDoor(){
                ^
THESIS_2 error: expected '}' at end of input
 }
 ^
Multiple libraries were found for "Adafruit_Fingerprint.h"
 Used: C:\Users\asus\Documents\Arduino\libraries\Adafruit_Fingerprint_Sensor_Library
 Not used: C:\Users\asus\Documents\Arduino\libraries\fing
exit status 1
'getFingerprintIDez' was not declared in this scope

ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2004
 

The function "getFingerprintIDez", "OpenDoor" cannot be found ....

It looks like one ot the other accolade ( { or } ) is missing.
You'll have to go through your code and see where you're missing one....


ReplyQuote


Page 1 / 5

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: