[Beginner] Reading a colon separated input (ASCII?)

Hello.

First of all, I must say that I am just starting with Arduino. So I know what I am going to ask si very simple but I couldn't find how to do it. I read the ReadASCIIString tutorial but I am still confused.

I want to start with something very basic by making a LED on/off constant or on/off blinking. Thus, I want to send this through the serial port:

-const:0 (set the LED off)
-const:1 (set the LED on)
-blink:number (set the LED on with a blinking delay equal to the number)

Here is the code I have so far. Right now my input are just 0 or 1 and it works fine.

int led = 13;

void setup() {
  Serial.begin(9600);
      pinMode(led, OUTPUT); 
}

void loop() {
  // read the sensor:
  if (Serial.available() > 0) {
    int inByte = Serial.read();

    switch (inByte) {
    case '0':    
      digitalWrite(led, LOW);
      break;
    case '1':    
      digitalWrite(led, HIGH);
      break;
    }
  }
}

And what I would like to do is the following. The code is wrong but it is just to give a more precise idea.

int led = 13;

void setup() {
  Serial.begin(9600);
      pinMode(led, OUTPUT); 
}

void loop() {
  if (Serial.available() > 0) {
    char inByte = Serial.read();
    char mode = *something to take the first part of the input*
    if (mode=='const') {
      int on_off = *part after the colon*
      switch (on_off) {
      case '0':    
        digitalWrite(led, LOW);
        break;
      case '1':    
        digitalWrite(led, HIGH);
        break;
    } 
    else if (mode=='blink') {
      int time = *part after the colon*
      digitalWrite(led, HIGH);
      delay(time);
      digitalWrite(led, LOW);
      delay(time);  
    }
  }
}

Thanks for your help.

Also, replacing "const:" with "C" (for example) and "blink:" with "B" will simplify the work on the Arduino side.

...R

Hello,

Thanks for your answers.

Robin2:
Also, replacing "const:" with "C" (for example) and "blink:" with "B" will simplify the work on the Arduino side.

Yes, the "const" and "blink" where here mostly for explanation.

And thanks Nick. I think the one I need is the "State Machine" example.
I also found the function "Serial.readBytesUntil()" which seems interesting for my needs.