How I can divide information stream from bluetooth hc-06? All good afternoon or evening. I am having a problem writing a sketch for Arduino using Arduino UNO and Bluetooth HC - 06.

My program does not divide the input stream of information into several variables. No matter how many variables I specify, they are considered as one. 

Maybe I do not know all subtleties of the use of Serial.read(). Apparently from a sketch given below I get through Bluetooth two variables of color and var. A microcontroller perceives these two variables as one and as a result does not execute before him task. As a result we will be able to choose the color and change delay of blinking by this color.

If anybody knows how to correct this problem or can point me to a similar project I will be very thankful for any rendered help

const int rPin = 3;
const int gPin = 5;
const int bPin = 6;
int chosed_color;
int val; 
int color;

void setup() 
{
  Serial.begin(9600);
  pinMode( rPin, OUTPUT );
  pinMode( gPin, OUTPUT );
  pinMode( bPin, OUTPUT );

}

void loop() 
{
while(Serial.available()&gt;0)
  {
     color = Serial.read();
   if(color==1)
      {
       chosed_color = rPin;
      digitalWrite( rPin, HIGH );       
      digitalWrite(rPin, LOW);  
       return chosed_color;
      }
        else if(color==2)
      {
       chosed_color = bPin;
       digitalWrite( bPin, HIGH );     
      digitalWrite(bPin, LOW);  
       return chosed_color;
      }
         else if(color==3)
      {
        chosed_color = gPin;
       digitalWrite( gPin, HIGH );
       digitalWrite(gPin, LOW);  
       return chosed_color;
      }
  }
if(Serial.available()&gt;0) 
{
  val = Serial.read();
}

      digitalWrite( rPin, HIGH );
      delay(val);       
      digitalWrite(rPin, LOW);  
      delay(val); 
}
Your code have various issues.

This:

   if(color==1)
      {
       chosed_color = rPin;
      digitalWrite( rPin, HIGH );       
      digitalWrite(rPin, LOW);  
       return chosed_color;
      }


means that when you find a color, you exit loop() instead of reading the val variable.

Serial.read

Serial.read read only one byte. If you need to read an arbitrary integer, need Serial.parseInt or some elaborate solution. As it, you are only able to read one-digit integer values.

Worse, when you type "1" in the Serial Monitor, what the program received is the value 49 (the ascii code for char 1).

Also, you have to filter non interesting chars, like LF, CR, commas or whatever char you use as delimitir.

Please, read the excelent post by Majenko about Reading Serial on the Arduino.

Here a better version of your code. It is very basic and lacks all error checking, etc.

const int rPin = 3;
const int gPin = 5;
const int bPin = 6;
int pins[3] = {rPin, gPin, bPin};

void setup()
{
    Serial.begin(9600);
    pinMode(rPin, OUTPUT);
    pinMode(gPin, OUTPUT);
    pinMode(bPin, OUTPUT);
}

void loop()
{
    if(Serial.available()&gt;0) {
        int color = Serial.read();
        int chosed_color = pins[color-1];
        digitalWrite(chosed_color, HIGH);
        digitalWrite(chosed_color, LOW);

        if(Serial.available()&gt;0) {
            int val = Serial.read();
            digitalWrite(chosed_color, HIGH); // I suppose you want this
            delay(val);
            digitalWrite(chosed_color, LOW);
            delay(val);
        }
    }
}