Need help with switch case for triggering only once until prompted again

Hello, I'm rather new with this so for anyone willing to take the time to help me with this issue, could I ask for an explanation or rationale behind why / how something is / should be done? I would sincerely appreciate your effort in assisting my learning.

So I have a sketch with several switch cases triggered from a simple GUI, for the most parts I can get my cases to loop on themselves which is what I desired (I'm still not too sure about the logic of why that works) but when it comes to running only once I'm stumped, my logic or argument is definitely wrong but I can't seem to figure it out.

Case 6 is where I would like to have it trigger just once, is there something I can do to have it perform once till the next time the case is called?

What happens now is that when Case 6 is triggered the LED remains HIGH indefinitely.

Very much appreciate everyone's input

//----------CONSTANTS

const int thisPin = 13; //assigning the variable "thisPin" the number 13

//----------VARIABLES
int val;  // declaring 'val' from Processing as an integer
long previousMillis = 0;  // declaring variable previousMillis as 0
long interval_1 = 1000; // declaring variable of 'interval_1' = 1000 ms
long interval_5 = 5000; // declaring variable of 'interval_5' = 5000 ms
long interval_10 = 10000; // declaring variable of 'interval_10' = 10000 ms

long startTime = 0;
long oneMinute = 60000;
bool ledState = LOW; // declaring the state of LED as false = off

void setup() {

pinMode(thisPin, OUTPUT);  //setup indicating the mode of the pin named 'thisPin' as OUTPUT
digitalWrite(thisPin, ledState);  // setup declares that at the start of the program the state of the LED is in the state indicated 
                                  // as per bool ledState = false;
Serial.begin(9600);                                  

}// end setup

void loop() {

 if(Serial.available() >0){ //Serial.available is to look at Processing to see if there's a value to pass
    val = Serial.read();  //Serial.read is to read the number from Processing and pass it to 'val'
 }

  unsigned long currentMillis = millis(); //unsigned means >= 0 values only, long means the number is long.
  unsigned long startTime; 
 

  switch(val){  // if a 'val' is read from Processing, it is passed down to 'switch' which then activates the 'case' based on the 'val'
    
    case '1': // case of 'val' = 1 from Processing this means the button we assigned as '1'
      digitalWrite(thisPin, HIGH);  // On LED
    break;

    case '2':
      digitalWrite(thisPin, LOW); // Off LED
      previousMillis = 0;
      currentMillis = 0;
      ledState = LOW;
    break;

    case '3':
      if((unsigned long)(currentMillis - previousMillis) >= interval_1){  //if positive value of current time - just now time >= interval_1(1000)
        ledState = !ledState; // the state of LED does not equal the state of LED, means opposite only
        digitalWrite(thisPin, ledState);  // writes the LED pin into the state that is opposite whatever state it was
        previousMillis = millis();  //the time this code is run is now registered as current time and resets the loop.
      }break;
      
    case '4':
      if((unsigned long)(currentMillis - previousMillis) >= interval_5){  // blink at interval of 5000ms
        ledState = !ledState; // state of LED does not equal current state of LED
        digitalWrite(thisPin, ledState);  // writes the LED pin into the state that is opposite whatever state it was
        previousMillis = millis();  // the time this code starts running is now registered as the current time
      }break;
      
     case '5':
      if((unsigned long)(currentMillis - previousMillis) >= interval_10){ // blink at interval of 10000ms
        ledState = !ledState; // state of LED does not equal current state of LED
        digitalWrite(thisPin, ledState);  // write the LED pin into the state that is opposite whatever state it was in
        previousMillis = millis();  // time this code starts running is now registered as the current time
      }break;
      
      case '6': 
        ledState = HIGH; // force LED into HIGH
        digitalWrite(thisPin, ledState); // LED enters mode opposite to what it is supposed to be (LED should turn on at the start)
        startTime = millis();
        if(currentMillis - startTime >= oneMinute){ // keep LED on for timeOn_1 = 60000ms (1 min)
          ledState = LOW;
          digitalWrite(thisPin, ledState);
      }break;
      
        
      
  }//end of switch

}//end of loop

The way I go about doing things once only is to use a boolean variable called something like iHaveDoneThisAlready, and initialise it as false.

Then, when it's time to do that thing (like in your example you enter case 6), check if iHaveDoneThisAlready is false. If it is, do the thing and set iHaveDoneThisAlready to true. Next time into that case, becasue iHaveDoneThisAlready is true, the thing won't happen again.

Of course, you will need some logic to set iHaveDoneThisAlready back to false sometime, or it will never ever happen again. Perhaps you would set it false in each other case, so that any "new" visit to case 6 will cause the thing to happen, but consecutive visits won't.

PS: an easier way of setting the flag back to false, rather than in each case other than 6, would be to test val before the switch section and if it's not 6, reset the flag.

You need to reset "val" when you are done with it otherwise the switch will continue to execute the last "val" if there is no new "val".