'introScreen was not declared in the scope

#include <Adafruit_Fingerprint.h>    //Libraries needed
#include <SoftwareSerial.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <EEPROM.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
#define coinSlot 6

int coinValue = 0;
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
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);
  digitalWrite(But1,LOW);
  pinMode(coinSlot, INPUT_PULLUP);
  Serial.begin(9600);               
  finger.begin(57600);             
  lcd.begin (16,2);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home();
  lcd.write(EEPROM.read(5));
  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);
    //If the button is pressed it opens the doorlock as the button is meant to be inside
    OpenDoor();
    introScreen();

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

I tried to check i was missing 1 bracket but now Im having the error code "Open door" was not declared in this scope

Your missing a { in the OpenDoor() function.

You still have a braces problem. If you use CTRL-T to clean up the indents, you will see it quickly. Look at the OpenDoor function. (After CTRL-T).

C:\Users\asus\Documents\MARVE THESIS\THESIS1\originalThesisDontTouch\originalThesisDontTouch.ino: In function 'void loop()':
originalThesisDontTouch:55:3: error: 'OpenDoor' was not declared in this scope
   OpenDoor();
   ^~~~~~~~
C:\Users\asus\Documents\MARVE THESIS\THESIS1\originalThesisDontTouch\originalThesisDontTouch.ino:55:3: note: suggested alternative: 'perror'
   OpenDoor();
   ^~~~~~~~
   perror
C:\Users\asus\Documents\MARVE THESIS\THESIS1\originalThesisDontTouch\originalThesisDontTouch.ino: At global scope:
originalThesisDontTouch:76:1: error: expected unqualified-id before 'while'
 while (coinInserted) {
 ^~~~~
originalThesisDontTouch:83:1: error: expected unqualified-id before 'if'
 if (coinCount >= requiredCoins) {
 ^~
originalThesisDontTouch:113:1: error: 'lcd' does not name a type
 lcd.print("Welcome"); {              //Printing a message for the recognized template
 ^~~
originalThesisDontTouch:113:23: error: expected unqualified-id before '{' token
 lcd.print("Welcome"); {              //Printing a message for the recognized template
                       ^
originalThesisDontTouch:126:1: error: expected unqualified-id before '{' token
 {
 ^
exit status 1
'OpenDoor' was not declared in this scope

This was the error code I got

void loop()
{
  int result = getFingerprintIDez();  //This function keeps looping and waiting for a fingerprint to be put on the sensor
  OpenDoor();
  introScreen();
  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);

    }
  }
}

I still dont get it sir sorry i have the same braceket sir {

Versus


void OpenDoor()
{
  digitalWrite(in2, LOW); // turn on motor
  delay(5000);
  digitalWrite(in2, HIGH); // turn off motor
}

  void OpenDoor()
  {
  digitalWrite(in2, LOW); // turn on motor
  delay(5000);
  digitalWrite(in2, HIGH); // turn off motor
}

After adding the bracket here now Im getting the error around here "expected unqualified-id before while"

while (coinInserted) {
  coinSlotSignal = digitalRead(coinSlot);
  if (coinSlotSignal > 0) {
    coinInserted = false;

  }

Hi

Show us the code "before while" please.

Have you counted and checked your { and } pairs?

What model Arduino are you using?

Tom... :grinning: :+1: :coffee: :australia:



originalThesisDontTouch:75:1: error: expected unqualified-id before 'while'
 while (coinInserted) {
 ^~~~~
originalThesisDontTouch:82:1: error: expected unqualified-id before 'if'
 if (coinCount >= requiredCoins) {
 ^~
originalThesisDontTouch:112:1: error: 'lcd' does not name a type
 lcd.print("Welcome"); {              //Printing a message for the recognized template
 ^~~
originalThesisDontTouch:112:23: error: expected unqualified-id before '{' token
 lcd.print("Welcome"); {              //Printing a message for the recognized template
                       ^
exit status 1
expected unqualified-id before 'while'

this is the full code

#include <Adafruit_Fingerprint.h>    //Libraries needed
#include <SoftwareSerial.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <EEPROM.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
#define coinSlot 6

int coinValue = 0;
int coinCount = 0;
int coinSlotSignal;
int requiredCoins = 1;
boolean coinInserted = false;
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);
  digitalWrite(But1, LOW);
  pinMode(coinSlot, INPUT_PULLUP);
  Serial.begin(9600);
  finger.begin(57600);
  lcd.begin (16, 2);
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home();
  lcd.write(EEPROM.read(5));
  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
  OpenDoor();
  introScreen();
  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);
}
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
}

Hi,
Have you checked your { and } pairs?

What model Arduino are you using?

Can you please tell us your electronics, programming, arduino, hardware experience?

Tom... :grinning: :+1: :coffee: :australia:

Hi Ive check all pairs all same .

arduino model was 1.8.14

My code was form a separated code and I just try to sink the 2 code as one
I will post my CODE for Fingerprint then my CoinSlot code The 2 code is working. But I dont know how to sink this 2 code so I just tried to get some code then Try but I'm incountering a lot of problem..

FINGER PRINT SOLENOID CODE

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

This one is a code form a COIN SLOT

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

schematic diagram

This is my project concept

Your use of braces is still very messed up. Did you use CTRL-T to align them? Look at the code after the end of loop().

This is the proper code sir but having problem if the coin is inserted its like it can detect 2 coins then someotimes 1 coin 3 coins on sometimes sstop detecting

can you please look at my code sir

#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] : "" 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 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();
  }
}
//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(in2, LOW); // turn on motor
  delay(5000);
  digitalWrite(in2, HIGH); // turn off motor
}

This does not compile. Your loop() function ends early because of the braces. This leaves the code after it orphaned and unreachable.

Adding the fingerprint code inside the loop sir will fix the issue?

Understand the Arduino code structure. You have declarations and global definitions. After that you have all of your functions. Two functions that you must have one of are setup(), which is executed once, and loop() which runs forever.

You can put all of your code in one large and messy blob inside of the loop function. I prefer to put my code into separate functions and call those functions from inside of loop(). This makes troubleshooting way easier. And in a year when you revisit the code, it will be less confusing.

Any code not in a function will never be executed. This is what you have now.

What if I try to use pin interrupt sir

You'll open up a whole world of pain and frustration for yourself

1 Like

:sleepy:

need help here

If you ask specific questions, we can provide assistance. If you want someone to fix it for you, then go to the Gigs and Collaborations category.

Did you write this code yourself? The basic structure of the program has problems and you ask about an advanced topic- interrupts?
Fix your structure problems before moving on.
(An interrupt, by the way, is simply a function that gets called by an external event.)