Ajuda/Help - Serial Comunication

Hello, I'm starting at the fantastic world of Arduino.
Today I was trying to do my Arduino to communicate through the serial port with the code below:

byte red;
byte green;
byte blue;
int p_red = 9;
int p_green = 10;
int p_blue = 11;

void setup()
{
Serial.begin(9600);
Serial.flush();
pinMode(p_red,OUTPUT);
pinMode(p_green,OUTPUT);
pinMode(p_blue,OUTPUT);
}

void loop()
{
Serial.print("Entre com o valor R: ");
red = Serial.read();
delay(5000);
Serial.print("Entre com o valor G: ");
green = Serial.read();
delay(5000);
Serial.println("Entre com o valor B: ");
blue = Serial.read();
delay(5000);
Serial.print("R ");
Serial.println(red);
Serial.print("G ");
Serial.println(green);
Serial.print("B ");
Serial.println(blue);
analogWrite(p_red,red);
analogWrite(p_green,green);
analogWrite(p_blue,blue);
delay(5000);
}

I wish my Arduino expected I give the answer by the computer before proceeding to the next line, you can do this?

Thanks!

PS.: I used Delay(), but I want to my Arduino wait until I write sometging.
PS.: I don't know, but this code don't work too. :confused:

You have several problems with that code. Have a look at the code in this thread: http://forum.arduino.cc/index.php?topic=323586.0. The original code is more complex than yours and it almost works. There are several solutions proposed.

Have a look at the examples in serial input basics - simple reliable ways to receive data without blocking.

There is also an example of a user question and response in planning and implementing a program.

...R