Coding Error Getting Unexpected Large Numbers

Hello Arduino form,

I hope you can help me solve the problem I am facing. I am using an UHF RFID reader with arduino due. I have used the commands the reader company provided for the reader to read tags. I am trying to do a project where I have two mode one will count the student in and who did not come. The other will only count the student who swiped. I added 10 variables called fc1ddddd fc2dddddd until 10 for the reader to be able to read only once. Initially their values are either 0 or 1. When I swipe the card and the reader start saving the id to compare and it reads more than 20 bytes for some reason all the values of fc1ddddd fc2dddddd until 10 becomes very large unexpected numbers. I tried to change the data type to Boolean yet I still got very large numbers which made no sense. I also tried making them as chars and still got weird characters on the serial monitor. How can I solve such a problem. The picture of the output when it is clear and then it changes from the serial monitor is attached.

inprogress.ino (13.6 KB)

int fc1ddddd=0; int fc2ddddd=0; int fc3ddddd=0; int fc4ddddd=0; int fc5ddddd=0; int fc6ddddd=0; int fc7ddddd=0; int fc8ddddd=0; int fc9ddddd=0; int fc10ddddd=0;

Any good reason for not using an array?

byte SetM2[]={0x53,0x57,0x00,0x25,0xFF,0x21,0xfc3ddddd,

“byte” ?

Serial1.write(SetM2,41);

I couldn’t be bothered to count. I bet the compiler is good at that.

if( (ID[0] == Fahad[0]) && (ID[1] == Fahad[1]) && (ID[2] == Fahad[2]) && (ID[3] == Fahad[3])&& (ID[4]==Fahad[4]) && (ID[5]==Fahad[5])&& (ID[6]==Fahad[6])&& (ID[7]==Fahad[7])&& (ID[8]==Fahad[8])&& (ID[9]==Fahad[9])&& (ID[10]==Fahad[10])&& (ID[11]==Fahad[11])) memcmp, FFS

I did not use an array because I did not think it would serve my purpose. I only wanted the values to be one or zero. I think Boolean would've been the best option, yet I still got unexpected values. This is the full code below.

I used bytes because the I must send bytes for the reader to response back the 0xfc3ddddd is a mistake that I just did by accident before uploading the code. I was trying to change the variable names as I notice when I change the name some of the unexpectedly work. For example the problem used to occur to a variable called ab i changed it to atddddd and then for some reason it started behaving normally. I just did ctrl f and replace all then it got replaced because the variable using to be called X a number that i forgot.

I did not use an array because I did not think it would serve my purpose.

I’d be interested to hear your reasoning.
Or, more likely, not.

Your code is simply too long. Too much repetition.

For example the problem used to occur to a variable called ab i changed it to atddddd and then for some reason it started behaving normally.

That’s just nonsense.

It has a lot of repetition for every student that is true. I wanted int fc1ddddd=0; int fc2ddddd=0; int fc3ddddd=0; int fc4ddddd=0; int fc5ddddd=0; int fc6ddddd=0; int fc7ddddd=0; int fc8ddddd=0; int fc9ddddd=0; int fc10ddddd=0; these values to make the reading of each id once.

f( (ID[0] == Fahad[0]) && (ID[1] == Fahad[1]) && (ID[2] == Fahad[2]) && (ID[3] == Fahad[3])&& (ID[4]==Fahad[4]) && (ID[5]==Fahad[5])&& (ID[6]==Fahad[6])&& (ID[7]==Fahad[7])&& (ID[8]==Fahad[8])&& (ID[9]==Fahad[9])&& (ID[10]==Fahad[10])&& (ID[11]==Fahad[11]))
        { Serial.println("id matched Fahd");
          if (fc1ddddd==0)
          {
          if(arival==1){
            ar+=1;
            Serial.println("Arrived student Fahad +1");
          //  Namear();
          }
         else if(start==1){
           atddddd+=1; 
             ab-=1;
              Serial.println("Attended student & absent Fahad +1 -1");
         //  Nameatddddd();
          }
         
          fc1ddddd=1;
         
          
         // verifyCheckIn();
          Serial.println("Fahad here");
        }       // else fc1=0;

In this code when the reader detect the tag the value of fc1 becomes 1 so when the card is swiped again it will not read it. I thought using a Boolean would be the best option but when I used it it was still giving these crazy large numbers. I did not think that an Array would be the best option but I could also try an Array.
I know that what I said about changing the variable name solved that issue is nonsense. It really is. Also, it solved it which made more nonsense. I really wish I could know why it did that. But again it did...

It has a lot of repetition for every student that is true

So, get rid of it.
Move forward.

I repeat the same procedure for each card but with different operations. I do not know what you mean by get rid of it.

What are the “different operations”?

Why aren’t you using memcmp?

Didn’t you get worried that your code got so big you couldn’t post it?

TheMemberFormerlyKnownAsAWOL:
What are the “different operations”?

Why aren’t you using memcmp?

Didn’t you get worried that your code got so big you couldn’t post it?

I mean for every ID it should response with the given name to the card. Also, I get the error for some IDs and some not. I wanted the reader to be able to see that maybe. I do not know what memcmp is but I will search for it. I did indeed but I wanted to show every detail because what I have noticed from the behavior of the reader is that the problem only occurs when the reader reads more than 20 bytes I tried to solve the issue with different ways but could not. I do not know how when the reader reads more than 20 bytes the

int fc1ddddd=0; int fc2ddddd=0; int fc3ddddd=0; int fc4ddddd=0; int fc5ddddd=0; int fc6ddddd=0; int fc7ddddd=0; int fc8ddddd=0; int fc9ddddd=0; int fc10ddddd=0;

some of these values get a very large number.

I mean for every ID it should response with the given name to the card.

Maybe the names should be in an array.

Shorter code gives the bugs fewer dusty corners to hide in

TheMemberFormerlyKnownAsAWOL:
Maybe the names should be in an array.

Shorter code gives the bugs fewer dusty corners to hide in

I will try to make the code shorter.