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');