title: Sending multiple values through serial port
body: <p>I am using an Arduino UNO for a project, however I don't know how to go about achieving what I want. I'm also a beginner therefore I sometimes don't know how to use some functions to do what I want.</p>
  
  <p>I basically want to send 3 values through the serial monitor all at once.</p>
  
  <p>The first value is a string that points to an operator (A, S, M, D, P), and then I want to take 2 more values. For example, if I input 'A012556 it should add 12 and 556 which will give me 568.</p>
  
  <p>Currently I am doing exactly this, but it's asking for each input separately. For example, it will ask for the operator (I can only input ints because I cannot get it to take string/chars) first, where I will input 1 (should be A for addition), and then it asks for the first number, and then the second number, and then adds them both together and outputs the result. This works fine, but it's not what I'm trying to achieve. </p>
  
  <pre><code>  Serial.println ("Enter your chosen operator");
    Serial.println ("A for Addition, S for Subtraction, M for Multiplication,");
    Serial.println ("D for Division, and P for Potentiometer: ");
  
    // Takes an input from the user
    int theOperator = dataInput();
  
    if (theOperator == 1) {
      // If input is equal to 1, carry out function 'addition()'
      addition();
    } else if ..............
  </code></pre>
  
  <p>Above is in the loop function currently, and it points to the function below. This is the same for subtract/multiply/divide/etc.</p>
  
  <pre><code>  void addition() {
  
    Serial.println ("A");
    Serial.println ("Please enter first number in format nnn: ");
    firstNumber = dataInput(); // Asks the user to input the first set of numbers
  
    /* Message must be in format cnnnnnn
       therefore first number must be greater than or equal to -99 and less than or equal to 999*/
    if (firstNumber &gt;= -99 &amp;&amp; firstNumber &lt;= 999) {
      Serial.println (firstNumber); // Prints the first set of numbers for the user to view
    }
    else {
      /* If the data input does not match the format cnnnnnn then this error message will display
         if the input is invalid the red LED will also turn on */
      digitalWrite(LED_RED, HIGH);
      Serial.println ("--------------- ERROR ---------------");
    }
  
    Serial.println ("Please enter second number in format nnn: ");
    secondNumber = dataInput(); // Asks the user to input the second set of numbers
  
    /* Message must be in format cnnnnnn
       therefore second number must be greater than or equal to -99 and less than or equal to 999*/
    if (secondNumber &gt;= -99 &amp;&amp; secondNumber &lt;= 999) {
      // The LED will turn off if it was previously on because this is a valid input
      digitalWrite(LED_RED, LOW);
      Serial.println (secondNumber); // Prints the second set of numbers for the user to view
    }
    else {
      digitalWrite(LED_RED, HIGH);
      Serial.println ("--------------- ERROR ---------------");
    }
  
    /* Give time for the red error LED to stay on
       for the user to notice he/she has made an invalid input */
    delay(500);
    digitalWrite(LED_RED, LOW);
  
    // As this case is for addition, it will add the first and second numbers
    value = (firstNumber + secondNumber);
  
    Serial.print("Value: ");
    // Prints the value of the two sets of numbers so that the user can see the value of their message
    Serial.println(value);
  }
  </code></pre>
  
  <p>Therefore is there any way of doing this? Do I need something like a substring?</p>
  
  <p>Thank you in advance, any advice would be appreciated.</p>