Help code for Serial Port, Using Words connected to ints

Gonna cut straight to the cheese, im trying to use Serial Port to send commands to my servo, i have it all worked out, but i have to type numbers in.

int IT1 = 120;

Essentially thats what i have, but i have to type in the 120, is there a way to make it so i have to type in “IT1” into the serial port to execute the same command?

You dont have to read the code unless you want to…

#include<Servo.h>

Servo servo1;

const int IT1 = 120;
const int IT2 = 45;
const int IT3 = 0;

int Order = 15;

// Example 4 - Receive a number as text and convert it to an int

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data
boolean newData = false;
int dataNumber = 1;  // new for this version

void setup() {
 
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
    
    servo1.attach(4);
    
}
void loop() {
    recvWithEndMarker();
    showNewNumber();  
        if (dataNumber == IT1){
          servo1.write(IT1);
          delay(1000);
          servo1.write(180);
          delay(1000);
          servo1.write(90);
          delay(1000);    
          dataNumber++;
     }  
     if (dataNumber == IT2){
          servo1.write(IT2);
          delay(1000);
          servo1.write(180);
          delay(1000);
          servo1.write(90);
          delay(1000);    
          dataNumber++;
     }
     if (dataNumber == IT3){
          servo1.write(IT3);
          delay(1000);
          servo1.write(180);
          delay(1000);
          servo1.write(90);
          delay(1000);    
          dataNumber++;
     }
     if (dataNumber ==Order){
          servo1.write(IT1);
          delay(1000);
          servo1.write(180);
          delay(1000);
          servo1.write(90);
          delay(1000);
          servo1.write(IT2);
          delay(1000);
          servo1.write(180);
          delay(1000);
          servo1.write(90);
          delay(1000);
          servo1.write(IT3);
          delay(1000);
          servo1.write(180);
          delay(1000);
          servo1.write(90);
          delay(1000);    
          dataNumber++;
     }
}

void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;  
      
    if (Serial.available() > 0) {
        rc = Serial.read();
        
        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}
void showNewNumber() {
    if (newData == true) {
        dataNumber = 0;             // new for this version
        dataNumber = atoi(receivedChars);   // new for this version
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        Serial.print("Data as Number ... ");    // new for this version
        Serial.println(dataNumber);     // new for this version
        newData = false;
    }
}

Great tutorial on using Serial. Go here and scroll down to the section labeled Communication and read through the two on Serial.

I believe it is "cut straight to the chase" not cheese.

Anyhow, if I understand you, you want to be able to issue a command from a serial terminal in the form of ITx, and then have a command executed based on the value of x? There are a number of ways you can do that, but probably the way you're thinking, it can't be done - variable names disappear during compilation and are replaced by memory addresses.

You could receive the input into a 4 char array (3 + NULL) and then use strcmp to test against "IT1", etc, or you could assign each of your options a numeric value via the enum function, parse the incoming data stream a use a switch function.

Others will likely offer additional advice, but there's a start for you.