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 😊Â