RFID Tag as security for arduino

I need to read a RFID tag in such a way that if a valid TAG is not recognised the microcontroller will never execute the main loop rendering the atmega chip useless. Once a valid tag is recognized it should run until reset or power off.

Any ideas to implement this?

What do you mean by

valid key

A number entered from a keypad? or RFID with specific code or a real physical key and a lock with contacts.

Also. What do you mean by

renders the chip useless.

What chip. The Arduino microcontroller chip ATMega series ??

rogerClark: What do you mean by

valid key

A number entered from a keypad? or RFID with specific code or a real physical key and a lock with contacts.

Also. What do you mean by

renders the chip useless.

What chip. The Arduino microcontroller chip ATMega series ??

An RFID with a specific code.

I mean until the Valid RFID is placed next to the reader the chip wont jump to the main loop and wont do anything,

Simple.Something like this sudo code should work

void setup()
{
while(1)
   if(rfReader.card() == myTagg) break;//If this doesn't match it will be in the while forever until a valid match is found
}

Most code that I seen to operate and RFID reader uses a long sketch that is present on the main loop. Thats what I want to avoid. Perhaps some library?

What RFID device are you using? How do you connect it(serial, i2c, spi)?

HugoPT: What RFID device are you using? How do you connect it(serial, i2c, spi)?

SPI interface

RFID-RC522

(deleted)

With RC522 you can use MFRC522 Library for Arduino which is available at here:

You can use this code modify to meet your needs:

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9


MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup() {
	SPI.begin();
    Serial.begin(9600);
	mfrc522.PCD_Init();
}

void loop() {
        
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}
        
        byte myid[4] ={0x47,0x9c,0x85,0xb5};   //Define Master Card UID here
        byte isok= 0;
        for (byte i = 0; i < mfrc522.uid.size; i++) {
          if (mfrc522.uid.uidByte[i]==myid[i]) {
             isok= isok+1;
          }
     
        }
 
        if (isok==4){ //Program To RUN
            Serial.println("Card Matched");
            delay(1000);
            mfrc522.PICC_HaltA();
           }
               
           else if (isok < 4){
           Serial.println("Card Did Not Match");
           delay(1000);
           mfrc522.PICC_HaltA();
           }
           
}

And you can check it out My new Door Unlock Project using this RC522 RFID Reader as an example: