Getting some errors in program of rfid tag/card reading

Namaste everyone,
i am Hitendra from INDIA,
i am just verify the id from rfid tag with the help of following project (code), according to the code when i scan the tag/card then it gives the output as i want but the amin problem is,
"When I scan the tag/card second time,then it not scanning. if I scan the card just after second scan then it gives output"
hence the sensor scan the tag/card one time and one time gets paralised so please suggest me some hint,errors,solution in the code so i can solve this query.
.
.
.
Thanking You ( '◡' )
code..,

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);  // RX, TX

int id[12] = { 0, 'F', 0, 0, 3, 3, 'A', 4, 7, 'E', 'E', 6 };
char reader;
int flag = 0;
void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() {
  if (mySerial.available()) {
    reader = mySerial.read();
    for (int i = 0; i < 12; i++) {
      if (id[i] == reader) {
        flag++;
        if (flag == 12) {
          Serial.print("ha flag 12 hai\n");
          flag = 0;
        }
      }
    }
  }
}

read() returns an 8-bit value and is you rftag reader returning ASCII chars?

should your ID be

or possibly

the serial processing doesn't look right..
try this..

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);  // RX, TX

//int id[12] = { 0, 'F', 0, 0, 3, 3, 'A', 4, 7, 'E', 'E', 6 };
byte id[] = { 0x0F, 0x00, 0x33, 0xA4, 0x7E, 0xE6 };
byte incomingId[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
int charCount = 0;
char reader;
int flag = 0;
void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() {
  
  if (mySerial.available()) {
    while (mySerial.available()) {
      byte abyte = mySerial.read();
      charCount++;
      if (charCount < sizeof(incomingId)) {
        incomingId[charCount] = abyte;
        if (charCount = sizeof(incomingId) - 1) {
          flag = 1;
        }
      }
    }
  }

  if (flag == 1) {
    //compare arrays..
    if (memcmp(id, incomingId, sizeof(id)) == 0) {
      Serial.println("Tag match");
    }

    //reset flag..
    flag = 0;
    //zero incoming id..
    memset(incomingId, 0, sizeof(incomingId));
  }
}

Thanks for your valuable appreciation...:v:
But your isn't work

In the my code I get output as I required
But only a problem happens
Is that it recieved the data "one after other"
.
.
.
Can you simplify the errors in the code please!

Is it this that prints "one after the other"?
Serial.print("ha flag 12 hai\n");

If so, replace print by println

no brother println just print on new line
by the way i solved this issue by writing another code
.
.
.
thanks for the help😊.

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