user3080: I am trying to send color() data from Processing to Arduino. 
Here is my code from Processing:
import processing.serial.*;
Serial myPort;

void setup(){
  myPort = new Serial(this, Serial.list()[7], 9600);
}


void draw(){
  color[] c1 = {color(99,0,0),color(255,0,0) };
  for (int i = 0; i < c1.length; i++ ){
    int value = int(red(c1[0]));
    myPort.write(value);
    println(value);
    delay(2000);
  }
}

It sends the 99.0 data to Arduino. Here is the Arduino code for getting:
void setup(){
  Serial.begin(9600);
}

void loop(){
  while(Serial.available() > 0){
    int recieved = Serial.read();    
      Serial.print(recieved);
    }
} 

The problem is when Arduino receive data it doesn't take one by one. When i watch Arduino serial monitor, the data comes at different chunks like, 9...99...999..9.. etc.
I am trying to send several color info from Processing into arduino, it might be a long array of value. What is the best way to achieve this?

user3866: int value = int(red(c1[0])); gives you 99 not 99.0
You could read a byte (that's what Serial.read returns; not an int), and make some decision based on that character, then read again.
Or, you could read all the available data till '\n' new line character comes. What println(value); line does it sends 99+'\n
Code:
// Buffer to store incoming commands from serial port
String inData;

void setup() {
    Serial.begin(9600);
    Serial.println("Waiting for Processing color...\n");
}

void loop() {
    while (Serial.available() > 0)
    {
        char recieved = Serial.read();
        inData += recieved; 

        // Process message when new line character is recieved
        if (recieved == '\n')
        {
            Serial.print("Arduino Received: ");
            Serial.print(inData);

            inData = ""; // Clear recieved buffer
        }
    }
}

In case this is not working change your processing code line:
myPort.write(value);
to 
myPort.println(value); 
or
myPort.write(value);
myPort.write('\n'); 


user1566: You have to implement a serial protocol.
This can be either binary or ASCII. Binary has the advantage that the messages are short and well structured due to fixed parameter size. ASCII has advantage that you can type the messages into the serial monitor for debugging and typically data bytes are numerical ('0', '1' etc) while message bytes are text ('setcolour' etc) which means conflicting bytes do not have to be escaped.
To get started, try the Messenger library. Note that #include "WProgram.h" has to be changed to #include "Arduino.h" in the .cpp and .h files.
For the set colour message, if you used something like:
setcolour,99,0,0,255,0,0\n
You could use Messenger to parse it like:
Preamble:
#include "Messenger.h"
Messenger message = Messenger(','); //Message values separated by ','

In setup():
message.attach(messageCompleted);

In loop():
while(Serial.available()) {
    byte inbyte = Serial.read();
    message.process(inbyte);
}

Then implement the callback function:
void messageCompleted()
{
    if (message.checkString("setcolour")) {
        colour1[0] = message.readInt();
        colour1[1] = message.readInt();
        colour1[2] = message.readInt();
        colour2[0] = message.readInt();
        colour2[1] = message.readInt();
        colour2[2] = message.readInt();
    }
}

where colour1 and colour2 store the two RGB values.

user3493: The 'best' solution depends on many things, your skill, the performance of the system, and the other tasks it needs to do in the available time. There are some examples of doing data transfer between Processing and the Arduino in the Arduino example programs. So it is worth looking through them.
There seems to be some inconsistencies in your question. 
You wrote "It sends the 99.0 data to Arduino", which has a decimal point. 
Yet the code is printing an int i.e. 
int value = int(red(c1[0]));
myPort.write(value); 

Further, the processing code only looks at the red component of c1[0]: 
int value = int(red(c1[0])); 

so it can only send a sequence of '9'. So that looks like a bug.
There are a few basic strategies to write data that can be easily read. Two popular ways are:

send fixed length messages, or prefix a message with the size of the
data, and have a fixed format of data. For example, use a one byte
count to say how many colours are being sent, then send three bytes,
in the same order, for each colour
use non-data bytes to separate the data. For example use a ','
between R, G or B and '\n' to mark the end of the data. To keep
things simple, never use those values as data values. That is pretty
much how programming languages work. It is much more complex to read
than fixed format data, but can give more flexibility.

Data is often sent as printable characters (e.g. 173 would be three bytes havig the ASCII values '1', '7', '3'). If it is fixed format, it would always be three bytes. For your purposes, I'd probably send each data byte as two hex characters (ASCII '0' to '9' and 'A' to 'F'. This is slightly more complex than pure binary. However it is fixed format, and more importantly it is easier to test by hand using the Arduino serial monitor, you can just type stuff and it is relatively easy to do. 
Pure binary data is much more difficult to fully test, and often relies on a piece of software which also needs testing.
Summary: There are a couple of ways, it is hard to say which is best. For simplicity try to make it simple by being fixed format.

3080: <p>I am trying to send color() data from Processing to Arduino. </p>

<p>Here is my code from Processing:</p>

<pre><code>import processing.serial.*;
Serial myPort;

void setup(){
  myPort = new Serial(this, Serial.list()[7], 9600);
}


void draw(){
  color[] c1 = {color(99,0,0),color(255,0,0) };
  for (int i = 0; i &lt; c1.length; i++ ){
    int value = int(red(c1[0]));
    myPort.write(value);
    println(value);
    delay(2000);
  }
}
</code></pre>

<p>It sends the 99.0 data to Arduino. Here is the Arduino code for getting:</p>

<pre><code>void setup(){
  Serial.begin(9600);
}

void loop(){
  while(Serial.available() &gt; 0){
    int recieved = Serial.read();    
      Serial.print(recieved);
    }
} 
</code></pre>

<p>The problem is when Arduino receive data it doesn't take one by one. When i watch Arduino serial monitor, the data comes at different chunks like, 9...99...999..9.. etc.</p>

<p>I am trying to send several color info from Processing into arduino, it might be a long array of value. What is the best way to achieve this?</p>
 3866: <p><code>int value = int(red(c1[0]));</code> gives you <strong>99</strong> not <strong>99.0</strong></p>

<p>You could read a byte (that's what <code>Serial.read</code> returns; <strong>not an int</strong>), and make some decision based on that character, then read again.</p>

<p>Or, you could read all the available data till <code>'\n'</code> new line character comes. What <code>println(value);</code> line does it sends <code>99</code>+<code>'\n</code></p>

<p>Code:</p>

<pre><code>// Buffer to store incoming commands from serial port
String inData;

void setup() {
    Serial.begin(9600);
    Serial.println("Waiting for Processing color...\n");
}

void loop() {
    while (Serial.available() &gt; 0)
    {
        char recieved = Serial.read();
        inData += recieved; 

        // Process message when new line character is recieved
        if (recieved == '\n')
        {
            Serial.print("Arduino Received: ");
            Serial.print(inData);

            inData = ""; // Clear recieved buffer
        }
    }
}
</code></pre>

<p>In case this is not working change your processing code line:</p>

<p><code>myPort.write(value);</code></p>

<p>to </p>

<p><code>myPort.println(value);</code> </p>

<p>or</p>

<pre><code>myPort.write(value);
myPort.write('\n'); 
</code></pre>
 1566: <p>You have to implement a serial protocol.</p>

<p>This can be either binary or ASCII. Binary has the advantage that the messages are short and well structured due to fixed parameter size. ASCII has advantage that you can type the messages into the serial monitor for debugging and typically data bytes are numerical ('0', '1' etc) while message bytes are text ('setcolour' etc) which means conflicting bytes do not have to be escaped.</p>

<p>To get started, try the <a href="http://playground.arduino.cc/Code/Messenger" rel="nofollow">Messenger library</a>. Note that <code>#include "WProgram.h"</code> has to be changed to <code>#include "Arduino.h"</code> in the <code>.cpp</code> and <code>.h</code> files.</p>

<p>For the set colour message, if you used something like:</p>

<p><code>setcolour,99,0,0,255,0,0\n</code></p>

<p>You could use <code>Messenger</code> to parse it like:</p>

<p>Preamble:</p>

<pre><code>#include "Messenger.h"
Messenger message = Messenger(','); //Message values separated by ','
</code></pre>

<p>In <code>setup()</code>:</p>

<pre><code>message.attach(messageCompleted);
</code></pre>

<p>In <code>loop()</code>:</p>

<pre><code>while(Serial.available()) {
    byte inbyte = Serial.read();
    message.process(inbyte);
}
</code></pre>

<p>Then implement the callback function:</p>

<pre><code>void messageCompleted()
{
    if (message.checkString("setcolour")) {
        colour1[0] = message.readInt();
        colour1[1] = message.readInt();
        colour1[2] = message.readInt();
        colour2[0] = message.readInt();
        colour2[1] = message.readInt();
        colour2[2] = message.readInt();
    }
}
</code></pre>

<p>where <code>colour1</code> and <code>colour2</code> store the two RGB values.</p>
 3493: <p>The 'best' solution depends on many things, your skill, the performance of the system, and the other tasks it needs to do in the available time. There are some examples of doing data transfer between Processing and the Arduino in the Arduino example programs. So it is worth looking through them.</p>

<p>There seems to be some inconsistencies in your question. </p>

<p>You wrote "It sends the 99.0 data to Arduino", which has a decimal point. </p>

<p>Yet the code is printing an <code>int</code> i.e. </p>

<pre><code>int value = int(red(c1[0]));
myPort.write(value); 
</code></pre>

<p>Further, the processing code only looks at the red component of c1[0]: </p>

<pre><code>int value = int(red(c1[0])); 
</code></pre>

<p>so it can only send a sequence of '9'. So that looks like a bug.</p>

<p>There are a few basic strategies to write data that can be easily read. Two popular ways are:</p>

<ul>
<li>send fixed length messages, or prefix a message with the size of the
data, and have a fixed format of data. For example, use a one byte
count to say how many colours are being sent, then send three bytes,
in the same order, for each colour</li>
<li>use non-data bytes to separate the data. For example use a ','
between R, G or B and '\n' to mark the end of the data. To keep
things simple, never use those values as data values. That is pretty
much how programming languages work. It is much more complex to read
than fixed format data, but can give more flexibility.</li>
</ul>

<p>Data is often sent as printable characters (e.g. 173 would be three bytes havig the ASCII values '1', '7', '3'). If it is fixed format, it would always be three bytes. For your purposes, I'd probably send each data byte as two hex characters (ASCII '0' to '9' and 'A' to 'F'. This is slightly more complex than pure binary. However it is fixed format, and more importantly it is easier to test by hand using the Arduino serial monitor, you can just type stuff and it is relatively easy to do. </p>

<p>Pure binary data is much more difficult to fully test, and often relies on a piece of software which also needs testing.</p>

<p>Summary: There are a couple of ways, it is hard to say which is best. For simplicity try to make it simple by being fixed format.</p>
