There are always a 100 ways to write code for a given problem, but here's one example that I think will do the same job.
// RGB RGB RGB RGB
byte bit_patterns [] = {B00000000,B00000010,B00000100,B00000001};
void loop()
{
if(mySerial.available() > 0)
{
char val = mySerial.read();
char b = bit_patterns[val - '0']; // note, no bounds checking, we could get a 'Z'
Serial.print("recieved:");
Serial.println(val); //Print what Arduino 1 is sending
digitalWrite(blueLed, b & 1);
b >>= 1;
digitalWrite(greenLed, b & 1);
b >>= 1;
digitalWrite(redLed, b & 1);
}
}
}
_____
Rob