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

[Solved] Windows - Arduino Solenoid Lock using FingerPrint with CoinCounter

65 Posts
2 Users
1 Likes
13.3 K Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
 

Good to see we're making progress 😊 

So, if there is no coin inserted, and no fingerprint read, you want to see a welcome message.
We could do that this way:

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);
    } else {
      lcd.setCursor(0, 0);
      lcd.print("WELCOME");
    }
  }
}

 

This may come with an issue that the displayed "TOTAL:" may disappear too fast.
We could use a timer for that if this is the case, or add a small delay (a delay may be undesirable though).

Something like this:

...
unsigned long StartTotalTime;
#define ReplaceTotalTime 2000  // keep Total visible for 2 seconds
...

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);
      StartTotalTime = millis(); // store this time
    } else {
      if(StartTotalTime+ReplaceTotalTime<millis()) { // 2 seconds passed? Then show "WELCOME"
        lcd.setCursor(0, 0);
        lcd.print("WELCOME");
      }
    }
  }
}

 

What this does:

1. We define StartTotalTime to store the time when a coin was inserted.
2. We define a wait time, before WELCOME replaces TOTAL in ReplaceTotalTime in milliseconds (1 second = 1000 milliseconds)
3. When a coin is inserted we reset StartTotalTime to the current time.
4. Each time we want to show "TOTAL:", we first check if the StartTotaltime + ReplaceTotal is less than the current time.
    If that is the case then we have waited indeed 2 seconds and the "TOTAL:" will be replaced by "WELCOME".

 

I hope that made sense 😊 


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans what if I want the lcd display that it will display " SECURED COIN VAULT " after "TOTAL" also after "WELCOME raven " ?


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
 

You'll have to define when either of these messages are show.

For example:

Default: SECURED COIN VAULT
At fingerprint: WELCOME
At coin insert: TOTAL

In that case you'd get something like this:

void loop() {
  int FingerPrintResult = getFingerprintIDez();

  if (FingerPrintResult != -1) { //This function keeps looping and waiting for a fingerprint to be put on the sensor
    lcd.setCursor(0, 0);
    lcd.print("WELCOME");
    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);
      StartTotalTime = millis(); // store this time
    } else {
      if(StartTotalTime+ReplaceTotalTime<millis()) { // 2 seconds passed? Then show "WELCOME"
        lcd.setCursor(0, 0);
        lcd.print("SECURED COIN VAULT");
      }
    }
  }
}

 

As with the delay we created with StartTotalTime and such, we may need something like this for the welcome message as well. You'll have to try and see if the message is visible long enough for your purposes.


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans Thanks sir all credits goes to you. I will try it sir


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans sir How can I upload a video here?


   
ReplyQuote


 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
 

You can drag a video simply on the text editor when writing a reply 😊 

Note: if the video is too big, you may get a warning and the video wil not be uploaded.
Let me know if this is the case, then I can see if I can help with that ...


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hansit says video is big


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
 

I see ... how big is the video file?


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans 140 mb


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans I wanted you to show the problem of the solenoid lock if I enter the fingerprint it sends 5 second delay to make the solenoid goes to lock again, but after that its like sensding signal to arduino board then it shows TOTA = to 9 


   
ReplyQuote


 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
 
Posted by: @kalilinux25

140 mb

Yikes! That's a huge video file. 😱 
You may want to pull that through something like Handbrake to optimize compression.
If you'd like you could dump the file on Dropbox, OneDrive or Google Drive (which ever of these you may be using) and share the file there.
I can download it and compress it, or at least see it 😊 


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans. Thanks for understanding sir https://drive.google.com/file/d/1dxYtB-8TO8wKrY-sw2tPILIHh5X9W9fB/view?usp=drivesdk


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans someone suggested that I might need to usea aboolean function for may pin of pin 4 and make it false


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
 

Wel, I've pulled your video quickly through Handbrake and it's only 3 Mb now 😉 

 

Can you post the full code?
I did see one potential typo, corrected here .. but I'd need to see the full code to determine what else may be wrong.

void loop() {
  int FingerPrintResult = getFingerprintIDez();

  if (FingerPrintResult != -1) { 
    lcd.setCursor(0, 0);
    lcd.print("WELCOME");
    OpenDoor();
  } else {
    coinInserted = digitalRead(coinSlot); // < ----- changed this

    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);
      StartTotalTime = millis(); // store this time
    } else {
      if(StartTotalTime+ReplaceTotalTime<millis()) { // 2 seconds passed? Then show "WELCOME"
        lcd.setCursor(0, 0);
        lcd.print("SECURED COIN VAULT");
      }
    }
  }
}

   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans i ve found the answer sir using a diode 


   
Hans reacted
ReplyQuote


Page 4 / 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: