Strings and how to use them

I am pretty noob when it comes to arduino to computer communication. Recently, though, I've been trying out some new things, such as reading some Strings built-in examples, and wanted to try out myself.

But there's the problem : I don't know how.

I just wanted to a simple test : write "run blink demo" in the serial monitor, arduino would recognise it and would run the blink sequence 10 times.

I have this so far :

int index[16];
String blinkDemo = "run blink demo";
int x = 0;

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

void loop() {
  while (Serial.available() > 0) {
    index[x] = Serial.read();
    x += 1;
  }
}

I don't know how to procced or even if I need Strings on this! Can somebody please help me?

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

thank you