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, and store it in an array of characters.
Code:
char inData[20]; // Allocate some space for the string
char inChar; // Where to store the character read
byte index = 0; // Index into array; where to store the character
void setup(){
Serial.begin(9600);
}
void loop()
{
while(Serial.available() > 0) // Don't read unless
// there you know there is data
{
if(index < 19) // One less than the size of the array
{
inChar = Serial.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
// Now do something with the string (but not using ==)
}
Thanks to PaulS :Re: Help with Serial.Read() getting string.