Send Color value from Processing into Arduino I know this has been asked before, but I'm new to Arduino and Processing, and I'm trying to take this step by step.

I would like to pass an RGB value from processing, into Arduino via the Serial.Write/Read.

I have my Processing as:

void draw(){

  //orange colour in RGB values
  color _rgbColor = color(255, 40, 0);

  //convert colour into hex
  String _hexColor = hex(_rgbColor, 6);

  //convert colour into binary
  String _binaryColor = binary(_rgbColor);

  //pass colour to port
  myPort.write(_hexColor);
  delay(500);
}


I assume I can just pass the HEX value straight across, right?

First problem I get is that I can't debug what my Arduino device is getting (when I run the Processing program, the Serial Monitor wont work. Seems like I can only use one or the other). I can print the myPort.read within my Processing after the delay, and I get:


  -1


So I'm not quite sure what I'm doing wrong there. 

On the Arduino side, I'm using Serial.read() to retrieve the Serial data, which I assume will all be broken down into bytes, so I need to then convert it into a HEX formate, right?

----- Update -----

I now know that I need to break down my color variable into a char-message. I'm guessing I can do something like this then, for example: And then on the other side (Arduino), I need to rebuild the message, right?

if(mousePressed == true){
    //Red
     myPort.write('2'); 
     myPort.write('5'); 
     myPort.write('5');
     myPort.write(','); 

     //Green
     myPort.write('0'); 
     myPort.write('3'); 
     myPort.write('0');
     myPort.write(','); 

     //Blue
     myPort.write('0'); 
     myPort.write('0'); 
     myPort.write('0');
     myPort.write('\n'); 
  }


My Arduino script is as follows, is this an okay route to go down?

String message;
void loop() {

  int _size = Serial.available();

  if(_size &gt; 0){

    char value = Serial.read();
    message += value;

    //full message received (255,255,255)
    if(message.length() == 11){
      String _red = message.substring(0,3);
      String _green = message.substring(4,7);
      String _blue = message.substring(8,11);
      Serial.println("R:" + _red + " G:" + _green + " B:" + _blue);

      //apply to light system
      setColour(_red.toInt(), _green.toInt(), _blue.toInt());

      //clear buffer
      message = "";
      Serial.flush();
    }
  }
}
Add print(_hexColor); to you processing sketch. The value it's sending should appear in the Processing Console (at the bottom)