Hello buddy, please me in this code, i got an error showing "getID was not declared

#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int led1=6;
int led2=7;
int buzzer=3;
int dhanesh;
int pir=4;
int Detect= LOW;//whether detected as per state of sensor or not
int count=0;
int val_of_outPin=0;
#define RST_PIN 9
#define SS_PIN 10

byte readCard[4];
String MasterTag = "935D356"; // REPLACE this Tag ID with your Tag ID!!!
String tagID = "";

// Create instances
MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup()
{
lcd.init();
lcd.backlight();
SPI.begin(); // SPI bus
mfrc522.PCD_Init(); // MFRC522
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(buzzer,OUTPUT);
pinMode(pir,INPUT);
lcd.clear();
lcd.print(" Access Control ");
lcd.setCursor(0, 1);
lcd.print("Scan Your Card>>");
}

void loop()
{
Serial.begin(9600);
//Wait until new tag is available
val_of_outPin= digitalRead(pir);
if(val_of_outPin==HIGH){

if(Detect==LOW){
count=count+1;
Serial.print(count);
Serial.println(" Motions Detected");

Detect=HIGH;

}

while (getID())
{
lcd.clear();
lcd.setCursor(0, 0);

if (tagID == MasterTag) 
{
        
  lcd.print(" Access Granted!");
   digitalWrite(led1,HIGH); 
   digitalWrite(led2,LOW);
   tone(buzzer,4000);
   delay(500);
   noTone(buzzer);
   
  // You can write any code here like opening doors, switching on a relay, lighting up an LED, or anything else you can think of.
}
else
{
   digitalWrite(led2,HIGH); 
   digitalWrite(led1,LOW);  
  lcd.print(" Access Denied!");
  tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
     tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
    tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
    tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
     tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
}
 
  lcd.setCursor(0, 1);
  lcd.print(" ID : ");
  lcd.print("confidential");
   
delay(2000);
 digitalWrite(led2,LOW); 
 digitalWrite(led1,LOW);
lcd.clear();
lcd.print(" WELCOME HOME! ");
lcd.setCursor(0, 1);
lcd.print("Scan Your Card>>");

}
}else{

if(Detect==HIGH){
Serial.println("Motion Ended");
Detect= LOW;
}
lcd.noBacklight};

//Read new tag if available
boolean getID()
{
// Getting ready for Reading PICCs
if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
return false;
}
if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
return false;
}
tagID = "";
for ( uint8_t i = 0; i < 4; i++) { // The MIFARE PICCs that we use have 4 byte UID
//readCard[i] = mfrc522.uid.uidByte[i];
tagID.concat(String(mfrc522.uid.uidByte[i], HEX)); // Adds the 4 bytes in a single String variable
}
tagID.toUpperCase();
mfrc522.PICC_HaltA(); // Stop reading
return true;
}

Are you sure about that?

Check that each { has a matching }

Please remember to use code tags when posting code.

please help me in this if you get this

Where did you get the code?

i resolved
lcd.noBacklight};

my error is shown in the "while (getID())"

Did you match the { with the } ?

Please post the actual error message, and try using the IDE's auto format tool on your code.

Where did you get the code?

wait i will upload the code file

#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int led1=6;
int led2=7;
int buzzer=3;
int pir=4;
int Detect= LOW;//whether detected as per state of sensor or not
int count=0;
int val_of_outPin=0;
#define RST_PIN 9
#define SS_PIN 10

byte readCard[4];
String MasterTag = "935D356"; // REPLACE this Tag ID with your Tag ID!!!
String tagID = "";

// Create instances
MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup()
{
lcd.init();
lcd.backlight();
SPI.begin(); // SPI bus
mfrc522.PCD_Init(); // MFRC522
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(buzzer,OUTPUT);
pinMode(pir,INPUT);
lcd.clear();
lcd.print(" Access Control ");
lcd.setCursor(0, 1);
lcd.print("Scan Your Card>>");
}

void loop()
{
Serial.begin(9600);
//Wait until new tag is available
val_of_outPin= digitalRead(pir);
if(val_of_outPin==HIGH){

if(Detect==LOW){
count=count+1;
Serial.print(count);
Serial.println(" Motions Detected");

Detect=HIGH;

}

while (getID())
{
lcd.clear();
lcd.setCursor(0, 0);

if (tagID == MasterTag) 
{
        
  lcd.print(" Access Granted!");
   digitalWrite(led1,HIGH); 
   digitalWrite(led2,LOW);
   tone(buzzer,4000);
   delay(500);
   noTone(buzzer);
   
  // You can write any code here like opening doors, switching on a relay, lighting up an LED, or anything else you can think of.
}
else
{
   digitalWrite(led2,HIGH); 
   digitalWrite(led1,LOW);  
  lcd.print(" Access Denied!");
  tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
     tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
    tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
    tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
    delay(500);
     tone(buzzer,1000);
   delay(500);
    noTone(buzzer);
}
 
  lcd.setCursor(0, 1);
  lcd.print(" ID : ");
  lcd.print("confidential");
   
delay(2000);
 digitalWrite(led2,LOW); 
 digitalWrite(led1,LOW);
lcd.clear();
lcd.print(" WELCOME HOME! ");
lcd.setCursor(0, 1);
lcd.print("Scan Your Card>>");

}
}else{

if(Detect==HIGH){
Serial.println("Motion Ended");
Detect= LOW;
}
lcd.noBacklight();};

//Read new tag if available
boolean getID()
{
// Getting ready for Reading PICCs
if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
return false;
}
if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
return false;
}
tagID = "";
for ( uint8_t i = 0; i < 4; i++) { // The MIFARE PICCs that we use have 4 byte UID
//readCard[i] = mfrc522.uid.uidByte[i];
tagID.concat(String(mfrc522.uid.uidByte[i], HEX)); // Adds the 4 bytes in a single String variable
}
tagID.toUpperCase();
mfrc522.PICC_HaltA(); // Stop reading
return true;
}

And now with code tags, please.

#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int led1=6;
int led2=7;

#define RST_PIN 9
#define SS_PIN 10

byte readCard[4];
String MasterTag = "C920D9A3"; // REPLACE this Tag ID with your Tag ID!!!
String tagID = "";

// Create instances
MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup()
{
lcd.begin();
lcd.backlight();
SPI.begin(); // SPI bus
mfrc522.PCD_Init(); // MFRC522
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);

lcd.clear();
lcd.print(" Access Control ");
lcd.setCursor(0, 1);
lcd.print("Scan Your Card>>");
}

void loop()
{
Serial.begin(9600);
//Wait until new tag is available
while (getID())
{
lcd.clear();
lcd.setCursor(0, 0);

if (tagID == MasterTag) 
{
        
  lcd.print(" Access Granted!");
   digitalWrite(led1,HIGH); 
   digitalWrite(led2,LOW);
  // You can write any code here like opening doors, switching on a relay, lighting up an LED, or anything else you can think of.
}
else
{
   digitalWrite(led2,HIGH); 
   digitalWrite(led1,LOW);  
  lcd.print(" Access Denied!");
   
}
 
  lcd.setCursor(0, 1);
  lcd.print(" ID : ");
  lcd.print(tagID);
   
delay(2000);
 digitalWrite(led2,LOW); 
 digitalWrite(led1,LOW);
lcd.clear();
lcd.print(" Access Control ");
lcd.setCursor(0, 1);
lcd.print("Scan Your Card>>");

}
}

//Read new tag if available
boolean getID()
{
// Getting ready for Reading PICCs
if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
return false;
}
if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
return false;
}
tagID = "";
for ( uint8_t i = 0; i < 4; i++) { // The MIFARE PICCs that we use have 4 byte UID
//readCard[i] = mfrc522.uid.uidByte[i];
tagID.concat(String(mfrc522.uid.uidByte[i], HEX)); // Adds the 4 bytes in a single String variable
}
tagID.toUpperCase();
mfrc522.PICC_HaltA(); // Stop reading
return true;
}

this is the original code. i modify this code as per the need of our project

Go easy - you'll get a forum timeout if you keep posting too much.

Please go back to your last post and edit-in the code tags.

i didn't get u, what you are saying about

if i tell my project idea, could you help with my code?

I'm just going out for the evening, but I'm sure someone else will be along soon.

The compiler is correct, getID is not declared in your program.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.