Rfid control for rf24l01

hello everyone, my question is this.
now I am working on a project for a physically disabled individual.

I wrote a code, it will wirelessly transfer the value it reads from 5 potentiometers in the transmitter and 1 MPU 6050 to the receiver.

I wrote all the code but now I'm thinking of adding a system.

Without inserting the rfid card into the transmitter, the rf24l01 should not send any commands to the receiver, but when the card is inserted, it will start sending commands.
but i don't understand how to write a sketch i would be glad if you help me`
THIS IS TRANSMITTER CODES

  //TRANSMITTER CODES(ARM) by TroubleCoder (Emir Hamurcu)
#include <Servo.h>                    //Servo kontrol kütüphanesi
#include <SPI.h>                      //Modem ile iletişim sağlamamıza yadımcı olan kütüphane
#include "RF24.h"                     //Radyo modemi kontrol etmemize yardımcı olan kütüphane
#include "Wire.h"                     //TWI cihazlarıyla iletişim kurmamızı sağlayan kütüphane
#include "I2Cdev.h"                   //Mpu6050 modülünün arduino ile haberleşmesini sağlayan kütüphane
#include "MPU6050.h"                  //Mpu6050 modülünü çalıştırmamıza yardımcı olan kütüphane
#include "nRF24L01.h"                 //Radyo modemi kontrol etmemize yardımcı olan kütüphane
             





MPU6050 mpu;                          //MPU6050 modülünü mpu olarak adlandırdık
int16_t ivmeX, ivmeY, ivmeZ;          //İvme için x, y ,z değişkenlerini atadık
int16_t gyroX, gyroY, gyroZ;          //Gyro için x, y ,z değişkenlerini atadık

int derece[1]; //Yollanacak paketlerin toplam sayısı(MPU6050)

int data[6];                    //yollanacak paketlerin değişken ataması yapıldı

int pot1pin = A1;               // değişken Pot1 Analog1 bağlantısı yapıldı
int pot2pin = A2;              // değişken Pot2 Analog2 bağlantısı yapıldı
int pot3pin = A3;             // değişken Pot3 Analog3 bağlantısı yapıldı
int pot4pin = A4;            // değişken Pot4 Analog4 bağlantısı yapıldı
int pot5pin = A5;           // değişken Pot5 Analog5 bağlantısı yapıldı
int pot6pin = A6;          // değişken Pot6 Analog6 bağlantısı yapıldı

int Pot1deger;           // Pot1 değişken değeri atandı
int Pot2deger;          // Pot2 değişken değeri atandı
int Pot3deger;         // Pot3 değişken değeri atandı
int Pot4deger;        // Pot4 değişken değeri atandı
int Pot5deger;       // Pot5 değişken değeri atandı
int Pot6deger;      // Pot6 değişken değeri atandı


RF24 radio(9,10);                     //9 ve 10, CE ve CSN sinyallerinin bağlı olduğu dijital pin numaraları olarak atadık.
                                      
const uint64_t pipe = 0xE8E8F0F0E1LL; //Arduino'dan veri alacak olan modemin adresi.

void setup(void){

  Wire.begin();                       //Mpu6050 haberleşmesi başlatıldı
  mpu.initialize();                   //Mpu6050 hazırlandı
  Serial.begin(9600);                 //Seri haberleşmeyi başlat
  radio.begin();                      //Radio haberleşmeyi başlat.
  radio.openWritingPipe(pipe);        //Programın veri göndereceği alıcının adresini ayarla.
}

void loop(void){
  
{  
Pot1deger = analogRead(pot1pin);
Pot1deger = map(Pot1deger, 0, 1023, 0, 179);           
data[0] = Pot1deger;
radio.write(data, 1);
}

{
Pot2deger = analogRead(pot2pin);
Pot2deger = map(Pot2deger, 0, 1023, 0, 179);
data[0] = Pot2deger;
radio.write(data, 1);
}

{
Pot3deger = analogRead(pot3pin);
Pot3deger = map(Pot3deger, 0, 1023, 0, 179);
data[0] = Pot3deger;
radio.write(data, 1);
}

{
Pot4deger = analogRead(pot4pin);
Pot4deger = map(Pot4deger, 0, 1023, 0, 179);
data[0] = Pot4deger;
radio.write(data, 1);
}

{
Pot5deger = analogRead(pot5pin);
Pot5deger = map(Pot5deger, 0, 1023, 0, 179);
data[0] = Pot5deger;
radio.write(data, 1);
}

{  
Pot6deger = analogRead(pot6pin);
Pot6deger = map(Pot6deger, 0, 1023, 0, 179);
data[0] = Pot6deger;
radio.write(data, 1);
}
  

  
{
mpu.getMotion6(&ivmeX, &ivmeY, &ivmeZ, &gyroX, &gyroY, &gyroZ);  // hem gyro hem ivme değerlerinin hepsini oku 
derece[0] = map(ivmeX, 0, 17000, 0,179);                          //ivmeX okumayı başlat
 radio.write(derece, 1);                                         //RF24 ile sinyal yolla

}



}




 

THIS IS RECEIVER CODER

//RECEIVER CODES (ARM)  by TroubleCoder (Emir Hamurcu)

#include <Servo.h>     //Servo kontrol kütüphanesi.
#include <SPI.h>      //Modem ile iletişim sağlamamıza yadımcı olan kütüphane.
#include "RF24.h"    //Radyo modemi kontrol etmemize yardımcı olan kütüphane.

                     
Servo myServo1;          //servolara isim veriyoruz.
Servo myServo2;         //servolara isim veriyoruz.
Servo myServo3;        //servolara isim veriyoruz.
Servo myServo4;       //servolara isim veriyoruz.
Servo myServo5;      //servolara isim veriyoruz.
Servo myServo6;     //servolara isim veriyoruz.
Servo myServo7;    //servolara isim veriyoruz.


RF24 radio(9,10); //9 ve 10, CE ve CSN sinyallerinin bağlı olduğu dijital pin numaraları olarak atadık.   

const uint64_t pipe = 0xE8E8F0F0E1LL;//Arduino'dan veri alacak olan modemin adresi.


int data[6];         //Alınacak paketlerin toplam sayısı (POT)
int derece[1];     //Alınacak paketlerin toplam sayısı(MPU6050)


void setup(){

  myServo1.attach(15); //A1          //servo giriş pinlerini belirtioruz.
  myServo2.attach(16); //A2         //servo giriş pinlerini belirtioruz.
  myServo3.attach(17); //A3        //servo giriş pinlerini belirtioruz.
  myServo4.attach(18); //A4       //servo giriş pinlerini belirtioruz.
  myServo5.attach(19); //A5      //servo giriş pinlerini belirtioruz.
  myServo6.attach(20); //A6     //servo giriş pinlerini belirtioruz.
  myServo7.attach(21); //A6     //servo giriş pinlerini belirtioruz.
  
  
  
  radio.begin();                    //Radio haberleşmeyi başlat.
  radio.openReadingPipe(1, pipe);   //Programın veri alacağı alıcının adresini ayarla.
  radio.startListening();           //modemden dosya almayı başlat.
  }


void loop(){
  
if (radio.available()){
bool done = false;
while (!done){
{
done = radio.read(data, 1);
myServo1.write (data[0]);
}
{
done = radio.read(data, 2);
myServo2.write (data[0]);
}
{
done = radio.read(data, 3);
myServo3.write (data[0]);
}
done = radio.read(data, 4);
myServo4.write (data[0]);
{
done = radio.read(data, 5);
myServo5.write (data[0]);
}
{
done = radio.read(data, 6);
myServo6.write (data[0]);
}
}
}



 if (radio.available()){          //bu kod ise radio aktifse verilen komutu yerine getirir.
 bool done = false;
 while (!done){
 done = radio.read(derece, 1);  //eğer radio aktif ise derece(MPU6050(İvme sensörü)'ne bağlı servo) komutlarını çalıştır.
 
 myServo7.write (derece[0]);    //hangi servo hangi komutu çalıştıracağını belirtiyoruz. 
  
     }
   }
}

How to check that the RFID card is inserted - you will find in the examples for rfid library.
Next, create a global variable in the program, something like

bool RF24_send_allow = false;

If the RFID card is inserted - assign a variable to TRUE, if not - FALSE.
Well, then it’s simple - before sending the data, check the state of the variable and send only if it true.

Hi guy firstly thank you very much for reply my question and Could you add the code you sent to the sample code I sent, I just started coding with arduino.

Looked at your code, it is absolutely non-working. You're sending six potentiometer signals without distinguishing them one from another, so the receiver will be a complete mess.
It seems to me that for now adding something to this code is a waste of time, it should be rewritten first.

I tried to do it as follows: Each pot will turn 1 servo in the receiver part, I programmed them all, rf24 will run every data with example msg[0] command, can you look the receiver codes
can you tell or fix the problems in the code?

As a option you can pack and sent pot signals as an array where each potentiometer will be stored in its element, then there will be no confusion on the receiver side.

look the example.
Replace your six identical block in the loop with this one:

// array of potentiometer pins
int pot_pins[] = {A1, A2, A3, A4, A5, A6};

void loop(void){
// array for pot's data
uint8_t data[6] = {0};

// reading six potentiometers and populate the array
for (byte i =0; i<6; i++) {  
  uint16_t Pot_value = analogRead(pot_pins[i]);
  uint8_t  Pot_byte = map(Pot_value, 0, 1023, 0, 179);           
  data[i] = Pot_byte ;
}

radio.write(data, 6);
}