RFID-RC522 LED blink

Hi,

I’m stil new with arduino and I need programing help. I use code:

#include <SPI.h>
#include <RFID.h>

#define SDA_DIO 53
#define RESET_DIO 5

RFID RC522(SDA_DIO, RESET_DIO);

void setup()
{ 
  Serial.begin(9600);
  /* Enable the SPI interface */
  SPI.begin(); 
  /* Initialise the RFID reader */
  RC522.init();
}

void loop()
{
  /* Temporary loop counter */
  byte i;
  
  /* Has a card been detected? */
  if (RC522.isCard())
  {
    /* If so then get its serial number */
    RC522.readCardSerial();

    Serial.println("Card detected:");
    
    /* Output the serial number to the UART */
    for(i = 0; i <= 4; i++)
    {
      Serial.print(RC522.serNum[i],HEX);
      Serial.print(" ");
    }
    Serial.println();
    Serial.println();
  }  
}

Can anyone tell me how to using this code turn on LED knowing card detected number. But turn LED only with card which number I write in code

Can anyone tell me how to using this code turn on LED knowing card detected number.

Yes, but it should be pretty obvious. It is not rocket science to see where that code is printing the number of the card. Adding code there to compare the values being printed to some other values is really pretty easy.

But turn LED only with card which number I write in code

As opposed to some random values?

my card number is: A5 A3 FE B0 48
so how turn on LED then I use card with this number?

my card number is: A5 A3 FE B0 48

So? The important thing is what the code looks like to store that number.

so how turn on LED then I use card with this number?

if(theTagsMatch(RC522.serNum, myNumber))
{
   // Turn the LED on
}

All you have to do is write the theTagsMatch() function, with the correct input argument types and the correct return value. Should not take more than 10 minutes.

still dont know how to do this

still dont know how to do this

I guess you need to plan to get a failing grade, then.

YOU have the responsibility to try SOMETHING.

try but still nothing, I just need to know how to do this and then I can do what I was planning to do

try but still nothing

That's exactly what we've seen. Nothing.

if you cant help so just say that

if you cant help so just say that

I can help. What I won't do is do your homework for you.

all day try to find tutorial to turn on LED and try to find out how to do this so I think I do my homework and if you can help me why dont you do that. Then I see how it shold look like I understand there was my mistakes

The point Paul is making, you have not written any code to make 'mistakes'.

I dont write all my trys to do this. If you cant help me so whats the point of this forum?

If you cant help me so whats the point of this forum?

The point is NOT to do your homework for you. The point is to make you try something, post the code, explain what it did, and did not do, and what you expected it to do, or not do. Then, we can help you understand why what it did was not what you expected, and how to realign your expectations or fix your code.

There are three parts to what you are trying to do.
First, you need to store the valid tag in some form in the code. How you do that defines how easy it is to perform the next step. The best way to define the valid tag is in the same kind of array that the scanned tag is stored in, and in the same format. Now, you have not provided a link to the library that you are using, so WE can't tell you what that kind of array should be.

Second, you need to compare the contents of one array to another. That is a trivial operation, involving a boolean (they match or they don't) and a for loop. Even a beginner can read the documentation on the for loop and try something.

Third, you need to turn the LED on if the tags match, and presumably, off if they don't. Not rocket science at all.

So, which part of your homework is proving too difficult?

flimmer1979:
if (RC522.serNum(RC522.serNum,23 83 DE C7 B9)){

?? :cold_sweat:

Not even close.

RC522.serNum is not a function.