add a name to the value.

hello, need help. I want to add a name to the value. exemple.

String massive
NAME1 = 8867111
NAME2 = 8921255
NAME3 = 8226572

if
Code == 8867111
Code == 8921255
Code == 8226572

Serial.print(Code + NAME)

Thanks.

You will have to explain in more detail.

Do you mean that you receive the data "NAME1 = 8867111" and you want to be able to identify the number part and, if it matches, display the name part?

If so have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

I think the strstr() function will be suitable for checking the content.

...R

Required when scanning an RFID card if the ID is the same, adds a name to the ID and displays Serial.

This code illustrates how to do what, I think, that you want using arrays. If not, you will have to better explain the requirements of the program.

const char *names[] = {"NAME1", "NAME2", "NAME3", "NAME4"};
long ids[] = {8867111, 8921255, 8226572, 822854};
const int numIds = 4;

long testId = 8226572;
char thisName[16];  // will match the ID
long thisId;

void setup()
{
  Serial.begin(115200);
  for (int n = 0; n < numIds; n++)
  {
    if (ids[n] == testId)
    {
      strcpy(thisName, names[n]);
      thisId = ids[n];
    }
  }
  Serial.print("CODE = ");
  Serial.print(thisId);
  Serial.print("  NAME = ");
  Serial.println(thisName);
}

void loop()
{

}

And the output using the test ID.

CODE = 8226572 NAME = NAME3

hello I really appreciate the advice. but I still need to identify all the ids that are named and add the name to the URL lines:

void rfid_1() { //2 RFID vykdimas
  unsigned long rfidTagCode1 = 0;
  while (rfid1.available()) {
    setMessage("RFID pasiruoses nuskaitimui! skaitomi duomenis...");
    rfidTagCode1 = readRFIDCode1();
    setMessage("Duomenys: " + String(rfidTagCode1) + String(" Isejimas"));
    //postServer();
    if (millis() > codeReadDelayMaxMillis) {
      if
      ((rfidTagCode1 == 6146163) || //Admin ID
          (rfidTagCode1 == 8933716) || //Korteliu ID.....
          (rfidTagCode1 == 8867111) ||        
          (rfidTagCode1 == 8235383)) {
        setMessage("ATIDARYMAS");
        // openPulse();//Atidarymo pulsas
        //setMessage("SIUNCIAMI DUOMENYS...");
        digitalWrite(relay1, LOW);
        digitalWrite(rfid_led, HIGH);
        float ID_1 = rfidTagCode1;
        if (client.connect(server0, 80)) {
          Serial.println("PRISIJUNGA PRIE SERVERIO");
          // Thingspeak post:
          client.println("GET /update?api_key=xxxxxxxxx&field2=" + String(ID_1, 0) + " insert name by card ID??" + " HTTP/1.1");
          client.println("Host: api.thingspeak.com");
          client.println("Connection: close");
          Serial.println("ISSIUSTI DUOMENYS");
          client.println();
          delay(1500);
          digitalWrite(relay1, HIGH);
          digitalWrite(rfid_led, LOW);
       
        codeReadDelayMaxMillis = millis() + CODE_READ_DELAY;
      } else {
        setMessage("NEPAZISTAMAS ID!");
        for (int i = 0; i < 5; i++)
        {
          digitalWrite(rfid_led, HIGH);
          delay(200);
          digitalWrite(rfid_led, LOW);
          delay(200);
        }
      }
    } else {
      setMessage("Praleidziami tie patys duomenys");
      delay(250);
    }
  }
}