Serial Led blink

Hello,

I try to control 8 LED's thu serial communication. By controlling i mean i want to modify in real time blinking value time. The problem is that i don't know how to make a loop e.c. write 200 (milis) and then led's turn on an off at each 200ms interval and then still in serial communication to write another value, etc. Please i need a soltion :frowning: . Thnk you.

int leduri[] = {13,12,11,10,9,8,7,6,5}; // definim pinii led-urilor
String str = ""; // variabila de citire 
byte led;
boolean estePornit = false;


void setup()
{
  Serial.begin(9600); // pornim serial-ul
  for(int init = 0; init <= 8 ; init++){   // folosim o bucla for pentru a
    pinMode(leduri[init],OUTPUT);          // defini toate iesirile de pe ARDUINO
  }                                        // numara pana la 8 deoarece avem 8 led-uri
  Serial.println("Apasa 'ajutor' pentru a vedea toate comenzile");
}

void loop(){
 
  while(Serial.available()){
       str += (char) Serial.read(); // Read in one char at a time
       delay(5);
  }
  if(str == "ajutor")
  {
    ajutor();
    str = "";
  }else if(str == "on")
  {
    estePornit = true;
    pornesteLeduri();
    str = "";
  }else if(str == "off")
  {
    opresteLeduri();
    str = "";
    estePornit = false;
  }else if(isDigit(str.charAt(0)) && estePornit == true)
  {
    delayLeduri();
  }
  
  }

  void pornesteLeduri(){
     Serial.println("Led-uri pornite");
    for(int init = 0; init <= 8 ; init++){   
    digitalWrite(leduri[init],HIGH);          
  }     
  }
  void ajutor()
  {
    
  }

  void opresteLeduri()
  {
    Serial.println("Led-uri oprite");
    for(int init = 0; init <= 8 ; init++){   
    digitalWrite(leduri[init],LOW);  
    Serial.read();        
  } 
  }

  void delayLeduri()
  {
    int perioada = str.toInt();
    int temp = perioada;
    opresteLeduri();
    delay(perioada);
    pornesteLeduri();
    delay(perioada);
    str = "";
    
  }

in real time blinking value time.

Get rid of the calls to delay().
Have a look at the blink without delay example in the IDE for clues