Strange parsent behavior

Hi. I am trying to use parseint to control 3 LEDs over serial, put I am getting strange results. The program writes the values that are parsed to the serial monitor in the form "redval, greenval, blueval" only when something is in the buffer. However, I am getting output like "552, 0, 128" line after line, even though I did not send anything over serial. When I send "0,0,0" the output "0, 0, 0" is generated as expected but then it's back to "552, 0, 128"

Any ideas?

void setup() {
  // put your setup code here, to run once:
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
Serial.begin(115200);

}

void loop() {
  // put your main code here, to run repeatedly:
delay(1000);

int redval;
int blueval;
int greenval;

if (Serial.available()>0)
  {
    redval = Serial.parseInt();
    greenval = Serial.parseInt();
    blueval = Serial.parseInt();
    //Serial.println(Serial.read());
  }

Serial.print(redval);
Serial.print(", ");
Serial.print(greenval);
Serial.print(", ");
Serial.println(blueval);

}
if (Serial.available() >= 6)

Serial is slow, if 1 byte gets received, that does not mean 6 bytes are have been received, but you are trying to read them.

Just remember, you need to send 2 bytes for every int

You print the values for redval, greenval and blueval whether they've been updated or not. Also, since you don't give them an initial value, you're getting something random.

Change their declarations thus: and you may get different results

int redval=0;
int blueval=0;
int greenval=0;

The examples in serial input basics are simple reliable systems for receiving data.

...R