ID Locking System Not functioning/Char Array Converting

Hey everyone, I am unable to convert the receivedChars output (which is an ID scanned off a card) into inputID for further use. I have tried every single thing under the sun, copying arrays, strings, separate arrays, at this point I am about to give up. Can anybody PLEASE help me get the inputID to be any data format storing the same characters as the receivedChars? I have tested and everything else works properly except for that one little thing. Thank you in advance. :sob:

#include <Servo.h>

Servo servo1;
Servo servo2;

const byte numChars = 32;
char receivedChars[numChars];

boolean newData = false;
boolean slot1taken = false;
boolean slot2taken = false;
boolean slot3taken = false;
boolean unlocked = false;

char inputID = '0';

char slot1id = '0';
char slot2id = '0';
char slot3id = '0';

//open
int o = 90;
//closed
int c = 0;


void setup() {
    Serial.begin(115200);
    inputID = '0';
    servo1.attach(2);
    servo1.write(90);
    servo2.attach(3);
    servo2.write(90);
    Serial.println("The device is ready for use.");
}

void loop() {
    recieveWithStartEndMarkers();
    showNewData();
    if (inputID != '0'){
    unlock();
    if (unlocked == false){
      lock();
    }
    unlocked = false;
    debug();
    }
}

void recieveWithStartEndMarkers() {
    static boolean recieveInProgress = false;
    static byte ndx = 0;
    char startMarker = '%';
    char endMarker = '?';
    char received;
 
  if (Serial.available() > 0) {
        received = Serial.read();

        if (recieveInProgress == true) {
            if (received != endMarker) {
                receivedChars[ndx] = received;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recieveInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (received == startMarker) {
            recieveInProgress = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("Input Student ID: ");
        Serial.println(receivedChars);
        inputID = receivedChars;
        Serial.println(inputID);
        newData = false;
    }
}

void unlock () {
  if(slot1taken == true && inputID == slot1id && inputID != '0')
  {
    //unlock slot1
    servo1.write(o);
    slot1taken = false;
    slot1id = '0';
    unlocked = true;
    inputID = '0';
  }
  
  if(slot2taken == true && inputID == slot2id && inputID != '0')
  {
    //unlock slot2
    servo2.write(o);
    slot2taken = false;
    slot2id = '0';
    unlocked = true;
    inputID = '0';
  }
  
  if(slot3taken == true && inputID == slot3id)
  {
    //unlock slot3
    slot3taken = false;
    slot3id = '0';
    unlocked = true;
    inputID = '0';
  }
}

void lock(){
  if(slot1taken == false && inputID != '0')
  {
    //lock slot1
    servo1.write(c);
    slot1taken = true;
    slot1id = inputID;
    inputID = '0';
  }
  else if(slot2taken == false && inputID != '0')
  {
    //lock slot2
    servo2.write(c);
    slot2taken = true;
    slot2id = inputID;
    inputID = '0';
  }
  else if(slot3taken == false)
  {
    //lock slot3
    slot3taken = true;
    slot3id = inputID;
    inputID = '0';
  }
}
void debug(){
  if(inputID == "1234"){
  Serial.print("Slot 1 ID:");
  Serial.println(slot1id);
  Serial.print("Slot 2 ID:");
  Serial.println(slot2id);
  Serial.print("Slot 3 ID:");
  Serial.println(slot3id);
  inputID = '0';
  }
}

Check strcpy() in any good C book ( see more generally functions in stdlib.h or string.h)

You will need a separate char storageForCopy[numChars]; array of course

I have changed all of the array assignment functions to strcpy and made the appropriate changes, but it still displays the letter s when it is supposed to print the full inputID. (p.s. the IDs scanned typically start out with 24 and are 7 digits). Thank you for the advice though.

 #include <Servo.h>

Servo servo1;
Servo servo2;

const byte numChars = 32;
char receivedChars[numChars];

boolean newData = false;
boolean slot1taken = false;
boolean slot2taken = false;
boolean slot3taken = false;
boolean unlocked = false;

char inputID[] = "0";

char slot1id[] = "0";
char slot2id[] = "0";
char slot3id[] = "0";

//open
int o = 90;
//closed
int c = 0;


void setup() {
   Serial.begin(115200);
   servo1.attach(2);
   servo1.write(90);
   servo2.attach(3);
   servo2.write(90);
   Serial.println("The device is ready for use.");
}

void loop() {
   recieveWithStartEndMarkers();
   showNewData();
   if (inputID != "0"){
   unlock();
   if (unlocked == false){
     lock();
   }
   unlocked = false;
   debug();
   }
}

void recieveWithStartEndMarkers() {
   static boolean recieveInProgress = false;
   static byte ndx = 0;
   char startMarker = '%';
   char endMarker = '?';
   char received;

 if (Serial.available() > 0) {
       received = Serial.read();

       if (recieveInProgress == true) {
           if (received != endMarker) {
               receivedChars[ndx] = received;
               ndx++;
               if (ndx >= numChars) {
                   ndx = numChars - 1;
               }
           }
           else {
               receivedChars[ndx] = '\0'; // terminate the string
               recieveInProgress = false;
               ndx = 0;
               newData = true;
           }
       }

       else if (received == startMarker) {
           recieveInProgress = true;
       }
   }
}

void showNewData() {
   if (newData == true) {
       Serial.print("Input Student ID: ");
       Serial.println(receivedChars);
       strcpy(inputID, receivedChars);
       Serial.println(inputID);
       newData = false;
   }
}

void unlock () {
 if(slot1taken == true && inputID == slot1id && inputID != "0")
 {
   //unlock slot1
   servo1.write(o);
   slot1taken = false;
   strcpy(slot1id, "0");
   unlocked = true;
   strcpy(inputID, "0");
 }
 
 if(slot2taken == true && inputID == slot2id && inputID != "0")
 {
   //unlock slot2
   servo2.write(o);
   slot2taken = false;
   strcpy(slot2id, "0");
   unlocked = true;
   strcpy(inputID, "0");
 }
 
 if(slot3taken == true && inputID == slot3id)
 {
   //unlock slot3
   slot3taken = false;
   strcpy(slot3id, "0");
   unlocked = true;
   strcpy(inputID, "0");
 }
}

void lock(){
 if(slot1taken == false && inputID != "0")
 {
   //lock slot1
   servo1.write(c);
   slot1taken = true;
   strcpy(slot1id, inputID);
   strcpy(inputID, "0");
 }
 else if(slot2taken == false && inputID != "0")
 {
   //lock slot2
   servo2.write(c);
   slot2taken = true;
   strcpy(slot2id, inputID);
   strcpy(inputID, "0");
 }
 else if(slot3taken == false)
 {
   //lock slot3
   slot3taken = true;
   strcpy(slot3id, inputID);
   strcpy(inputID, "0");
 }
}
void debug(){
 if(inputID == "1234"){
 Serial.print("Slot 1 ID:");
 Serial.println(slot1id);
 Serial.print("Slot 2 ID:");
 Serial.println(slot2id);
 Serial.print("Slot 3 ID:");
 Serial.println(slot3id);
 strcpy(inputID, "0");
 }
}

You are setting aside only enough room for a one character string for each ID. Try:

char inputID[numChars] = "0";

char slot1id[numChars] = "0";
char slot2id[numChars] = "0";
char slot3id[numChars] = "0";

johnwasser:
You are setting aside only enough room for a one character string for each ID. Try:

Thank you, now the inputID gives a correct value, but the servos stopped functioning properly, they just go to the c position and stay there.