Receiving a binaric word from serial port

Hello Readers,
I have got a question to you,
How can the AT328 or AT168 receive a binaric word made of 8 bytes that sent from the RS-232, the serial port of the computer (COM port)?
What I want to do is to send a word to the AT328 or AT168 from the serial port (for example: 01001100) and accordingly to what I defined in the program (specific word will cause the processor send "0" and another word cause it to send "1" logic) make the processor sending "1" or "0" from one of his outports.
all of that is for controlling engine to move forward or backwords or not to move at all according to the word was sent from the COM port.
By the way, the engine works on three outputs: VCC and two GNDs. when I take the VCC and the first GND it moves forwards, when I take the VCC with the second GND, it moves backwords.

Thanks in advanced.

It's easier to determine how to do this if you do two things. First, understand and use proper terms. Words are a Microslop invention. Everyone else uses bytes and bits. It looks like you want to send an 8 bit value. That's one byte.

Second, show the sending code.

If the sender is indeed sending an 8 bit/1 byte value, one call to Serial.read() will read that byte.

How can the AT328 or AT168 receive a binaric word made of 8 bytes that sent from the RS-232, the serial port of the computer (COM port)?

Something like

byte x[8];

if (Serial.available >= 8) {
    for (int 1 = 0; i < 8; i++) {
       x[i] = Serial.read();       
    }
}

Although more is needed to make it reliable.

controlling engine to move forward or backwords

Why do you need 8 bytes for this?


Rob

well, first thanks for the help.
Secondly, I don't think I will use all of the combinations of the byte, but these 8 bits are what I have, nothing less or more...
Correct me if I'm wrong.
well, I want to define few binaric words and when I receive one of them from the serial port, according to my desicion, a specific device will start to work. this will happen with everyone of the 9 words I'm going to define in a program on the computer.
For example if this is part of what I defined:
01100100 - X move forwards
01110100 - X move backwords
01000100 - X doesn't move
so when the AT328 gets the first byte, it's gonna move the engine forwards, when it gets the second byte, it's gonna stop from moving and so on...
what do you think about that?
(That's mean I will have 9 words to control the engines, 3 for each engine)

Alright I think I'm beginning to get it.

Here's a simple (but ugly) code snippet.

#define MOTOR1_FWD   1
#define MOTOR1_BACK  2
#define MOTOR1_STOP  3

#define MOTOR2_FWD   4
#define MOTOR2_BACK  5
#define MOTOR2_STOP  6

#define MOTOR3_FWD   7
#define MOTOR3_BACK  8
#define MOTOR3_STOP  9


if (Serial.available > 0) {
   switch (Serial.read()) {

   case MOTOR1_FWD:
      motor_1_fwd_func();
      break;

   case MOTOR1_BACK:
      motor_1_back_func();
      break;

// etc etc for other 7 possibilities

  default:
    // error if we get here
}

Rob