I have a switch case statement that *should* take an input in the form of a string for example: A, S, M, D, P. I have tried numerous ways to make this work, as I am aware that a switch case only accepts ints. I have tried enum {}; I have tried Serial.read/Serial.readString; I have tried charAt(); but either they do not work and cause more errors, or I just don't know where I should put them. Therefore is it actually possible to change my code so it allows a string input for each case? At this point I have labelled them 1, 2, 3, 4, 5.

Also, I have exhausted my way around forums and questions to do with having if/else statements within a switch statement which is in the loop() function.

My code if very messy and long winded, I'm aware, but when I input 5 for the potentiometer readings, it will only print the current reading on the pot and turn on that particular light, instead I want it to continuously print out the readings and change as I turn the potentiometer, whilst either turning the LEDs on or off as I go around.

I have tried this code in a separate file (not in a switch case) and it works perfectly. I understand that it might be doing this because its not in a loop inside the switch case, and obviously the switch case ends in a break;. But I have tried a Do While loop, and I have tried while(1) loop, but it still will only output a single reading from the pot and then loop back to the start of the switch case again. 

Any suggestions would be extremely appreciated, thank you. 

```
char dataInput() {
  while (!Serial.available()) {
    //wait for the user to enter value
    ;
  }
  return Serial.parseInt();
}

long firstNumber, secondNumber, value;

#define LED_RED 5
#define LED_ORANGE 6
#define LED_YELLOW 9
#define LED_GREEN 10
#define LED_BLUE 11

int potValue; // The output value of the potentiometer 

/*int ledList[5] = {
  LED_RED,
  LED_ORANGE,
  LED_YELLOW,
  LED_GREEN,
  LED_BLUE
};*/

#define potPin A0 // The pin the potentiometer is located

void setup() {

  pinMode(LED_RED, OUTPUT);
  pinMode(LED_ORANGE, OUTPUT);
  pinMode(LED_YELLOW, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);

  pinMode(potPin, INPUT);

  Serial.begin(9600);
}

void loop() {

  Serial.println ("Enter your chosen operator");
  Serial.println ("1 for Addition, 2 for Subtraction, 3 for Multiplication, and 4 for Division");
  Serial.println ("5 for Potentiometer");

  char theOperator = dataInput(); // Allows the user to enter their chosen operator

  switch (theOperator) {

    case 1: // Case 1 is for 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 >= -99 && firstNumber <= 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
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      Serial.println ("Please enter second number in format nnn: ");
      secondNumber = dataInput(); // Asks the user to input the second set of numbers
      if (secondNumber >= -99 && secondNumber <= 999) {
        Serial.println (secondNumber); // Prints the second set of numbers for the user to view
      } else {
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      value = (firstNumber + secondNumber); // As this case is for addition, it will add the first and second numbers
      Serial.print("Value: ");
      Serial.println(value); // Prints the value of the two sets of numbers so that the user can see the value of their message
      break;
    /////////////////////////////////////////////////////////////////////////////////////////////

    case 2: // Case 2 is for Subtraction
      Serial.println ("S");
      Serial.println ("Please enter the first number in format nnn: ");
      firstNumber = dataInput();
      if (firstNumber >= -99 && firstNumber <= 999) {
        Serial.println (firstNumber); // Prints the first set of numbers for the user to view
      } else {
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      Serial.println ("Please enter second number in format nnn: ");
      secondNumber = dataInput();
      if (secondNumber >= -99 && secondNumber <= 999) {
        Serial.println (secondNumber); // Prints the second set of numbers for the user to view
      } else {
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      value = (firstNumber - secondNumber); // As this case is for subtraction, it will subtract the first and second numbers
      Serial.print("Value: ");
      Serial.println(value);
      break;
    /////////////////////////////////////////////////////////////////////////////////////////////

    case 3: // Case 3 is for Multiplication
      Serial.println ("M");
      Serial.println ("Please enter the first number in format nnn: ");
      firstNumber = dataInput();
      if (firstNumber >= -99 && firstNumber <= 999) {
        Serial.println (firstNumber); // Prints the first set of numbers for the user to view
      } else {
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      Serial.println ("Please enter second number in format nnn: ");
      secondNumber = dataInput();
      if (secondNumber >= -99 && secondNumber <= 999) {
        Serial.println (secondNumber); // Prints the second set of numbers for the user to view
      } else {
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      value = (firstNumber * secondNumber); // As this case is for multiplication, it will multiply the first and second numbers
      Serial.print("Value: ");
      Serial.println(value);
      break;
    /////////////////////////////////////////////////////////////////////////////////////////////

    case 4: // Case 4 is for Division
      Serial.println ("D");
      Serial.println ("Please enter the first number in format nnn: ");
      firstNumber = dataInput();
      // Division by 0 is not allowed
      if (firstNumber >= -99 && firstNumber <= 999 && firstNumber != 0) { 
        Serial.println (firstNumber); // Prints the first set of numbers for the user to view
      } else {
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      Serial.println ("Please enter second number in format nnn: ");
      secondNumber = dataInput();
      // Division by 0 is not allowed
      if (secondNumber >= -99 && secondNumber <= 999 && secondNumber != 0) { 
        Serial.println (secondNumber); // Prints the second set of numbers for the user to view
      } else {
        Serial.println ("--------------- ERROR ---------------");
        break;
      }

      value = (firstNumber / secondNumber); // As this case is for division, it will divide the first and second numbers
      Serial.print("Value: ");
      Serial.println(value);
      break;
    /////////////////////////////////////////////////////////////////////////////////////////////

    case 5: // Case 5 is for the Potentiometer
      Serial.println("P");
      potValue = analogRead(potPin); // Reads the value on the pin
      potValue = map(potValue, 0, 1023, 0, 32); // Changes the default range from 0 to 1023 to 0 to 32

      // The value depends on binary, but skipping 1
      // 2, 4, 8, 16, 32
      if (potValue >= 0 && potValue <= 2) {
        Serial.println(potValue); // Prints the values of the pot, allowing user to know what value they are on
        delay(500); // Slows down the reading

        digitalWrite(LED_RED, HIGH);
        digitalWrite(LED_ORANGE, LOW);
        digitalWrite(LED_YELLOW, LOW);
        digitalWrite(LED_GREEN, LOW);
        digitalWrite(LED_BLUE, LOW);
      } /////////////////////////////////////////

      else if (potValue >= 3 && potValue <= 4) {
        Serial.println(potValue);
        delay(500);

        digitalWrite(LED_RED, LOW);
        digitalWrite(LED_ORANGE, HIGH);
        digitalWrite(LED_YELLOW, LOW);
        digitalWrite(LED_GREEN, LOW);
        digitalWrite(LED_BLUE, LOW); 
      } /////////////////////////////////////////

      else if (potValue >= 5 && potValue <= 8) {
        Serial.println(potValue);
        delay(500);

        digitalWrite(LED_RED, LOW);
        digitalWrite(LED_ORANGE, LOW);
        digitalWrite(LED_YELLOW, HIGH);
        digitalWrite(LED_GREEN, LOW);
        digitalWrite(LED_BLUE, LOW);
      } /////////////////////////////////////////

      else if (potValue >= 9 && potValue <= 16) {
        Serial.println(potValue);
        delay(500);

        digitalWrite(LED_RED, LOW);
        digitalWrite(LED_ORANGE, LOW);
        digitalWrite(LED_YELLOW, LOW);
        digitalWrite(LED_GREEN, HIGH);
        digitalWrite(LED_BLUE, LOW);
      } /////////////////////////////////////////

      else if (potValue >= 17 && potValue <= 32) {
        Serial.println(potValue);
        delay(500);

        digitalWrite(LED_RED, LOW);
        digitalWrite(LED_ORANGE, LOW);
        digitalWrite(LED_YELLOW, LOW);
        digitalWrite(LED_GREEN, LOW);
        digitalWrite(LED_BLUE, HIGH);
      }
      break;
    default:
      Serial.println ("--------------- ERROR ---------------");
  }
}

```