I would like to active an output if the RFID is recognize the right ID and active an output during 10sec.
I have done the program with the delay but when I apply the millis all the times the output is on after recognize the right ID in RFID.
It's possible someone look the program and help me to see what is missing?
You are missing [ code ] tags. Some of your code is now italic and I know that the Arduino doesn't read italics. You can edit your post to correct the error.
Any time you have numbers in your variable names, you are doing something wrong. Read about the array concept and make your list of IDs into an array. Then you need another variable to keep track of how many there are but you can have a long, long list without copying out lots of code by hand.
..but you never use ok_rfid_2 anywhere, so this is just mess left behind from a previous edit?
;
The lonely semicolon is lonely.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
Don't use multi-line if() statements without braces ({}). You will cause yourself lots of forehead-slapping moments when you edit something and something else unrelated stops working.
Your code currently will always turn on the relay all the time that the tag is in range. Then it seems like you are using the F_TRIG object to turn it off at the moment that it goes out of range. But the text says "5 second"(sic) I don't see "5" anywhere in your program. I see 2 seconds in the TOF object?
What do you mean "During 10 sec"? You mean the relay only stays on for 10 seconds, even if the tag is still in range?
Can you please share with us exactly where you got plclib.h from?
stay a xx seconds ON an OUTPUT and switch OFF after the time.
but what the heck does this mean?
The pin will be an OUTPUT pin regardless of whether or not the correct RFID card was read, so that part of the statement is irrelevant. Setting a pin HIGH is trivial. Waiting until an interval has passed is simple. There are two ways to do it, as illustrated in the blink and blink without delay examples. Setting a pin LOW is trivial.
It looks like you would be better served by the TP object which will give an output of a defined time span. Your current code seems like it turns the output off 2 seconds after the input goes off.