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()>0){
while(Serial.available()>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:"&& red &&"G:"&& green &&"B:"&& 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