how to serial.read multiple vars at once [solved]

Hossa!

I got it :slight_smile: (with some help of a friend)
and thanks to the Board Members!

//arduino
  if(Serial.available() >= 2){

    switch (byte(Serial.read())){

    case 'r':
      colorRGB[0] = Serial.read();

      break;
      
    case 'b':
      colorRGB[1] = Serial.read();

      break;

    }
  }

Data is created like this: [R(val)G(val)B(val)R(val)G(val)B(val)]

Serial.available waits for 2 bytes to arrive, [R(val)]

then switch statement reads the first byte, [R(val)]
(clears it)

and the second byte containing RGB value goes into my array [(val)]
(clears it too)

//processing

  char rred = 'r'
  char ggreen = 'g'


void draw(){

  colorRed[0] = byte(rred);
  colorRed[1] = byte(mouseX);

  colorGreen[0] = byte(ggreen);
  colorGreen[1] = byte(mouseY);


Arduino.write(colorRed);
Arduino.write(colorGreen);

note that my code is thus far only for two colors...

regards!