LED Control through bluetooth I have an Android app that sends data to the arduino HC-06. It is however giving me colors i did not send to it. Eg. Red in place of green, white in place of red etc.
Here is a snippet of my android code that sends the data via bluetooth

 public void onColorChanged(int color) {
    BluetoothV2 bluetooth = new BluetoothV2();
    int r,g,b;
    r = Color.red(color);
    g = Color.green(color);
    b = Color.blue(color);
    bluetooth.Message(r+","+g+","+b);
 }


Here is a snippet of my arduino code

void loop() {  

if(Serial.available()&gt;0){

while(Serial.available()&gt;0){
   char inChar = (char)Serial.read();
   inputString += inChar;       
}    
   int red = Serial.parseInt();
   int green = Serial.parseInt();
   int blue = Serial.parseInt();
   color(red,green,blue);
   inputString = "";
   Serial.println("R:"&amp;&amp; red &amp;&amp;"G:"&amp;&amp; green &amp;&amp;"B:"&amp;&amp; blue);
  }
}  

void color (unsigned char red, unsigned char green, unsigned char blue){   
   analogWrite(redPin, 255-red);  
   analogWrite(greenPin, 255-green);
   analogWrite(bluePin, 255-blue);
}


Terminal data

               2,,,,,,,,,,,,,2,,5,,,,,,,,,,,,,,,,,,,,,,,,,02725,1,502725,,,,,,,,,02514,5,602515     ,5,3,,,,,025


Is the problem how i get the data though Serial.read()? Or what am i missing
int firstcomma = inputString.indexOf(',');
int secondcomma = inputString.indexOf(',',firstcomma+1);
String r = inputString.substring(0,firstcomma);
String g = inputString.substring(firstcomma+1,secondcomma);
String b =  inputString.substring(secondcomma+1);
red = r.toInt();
green = g.toInt();
blue = b.toInt();
Serial.print("R");
Serial.print(red);
Serial.print("G");
Serial.print(green);
Serial.print("B");
Serial.println(blue);   


This solved my problems.