Two motors don't work simultaneously on MotorShield v3

Dear friends! Help me please. I have Arduino Nano, MotorShield v.3 and two motors.
I would like to operate simultaneously two motors forward, backward and stop. I am going to control it via BlueTooth using HyperTerminal by pressing keys ‘w’, ‘s’, ‘x’.
Then I wrote very simple program. Here is it:

/* 
      w=119
a=97, s=115, d=100
      x=120
*/      

#include <AFMotor.h>

AF_DCMotor rMotor(3);
AF_DCMotor lMotor(4);

byte spd = 200;
byte Val;
byte LastVal;

void setup()
{
Serial.begin(9600);
}

void loop() 
{
  while(Serial.available())
  {
  Val = Serial.read();
  if (Val == 119) // w
    {
    delay(100);
    lMotor.run(FORWARD);    // if I comment this row...
    lMotor.setSpeed(spd);     //... this row...
    rMotor.run(FORWARD);
    rMotor.setSpeed(spd);
    }
  else if (Val == 115) // s
    {
    lMotor.run(RELEASE);       //... this row...
    rMotor.run(RELEASE);
    }  
  else if (Val == 120) //x
    {
    lMotor.run(BACKWARD);    //... this row...
    lMotor.setSpeed(spd);       //... and this one, then another motor works properly!
    rMotor.run(BACKWARD);
    rMotor.setSpeed(spd);
    }
  }
}

But it doesn’t work!!! No one motor revolves, and at the very first moment a hear slight sound of the motor that placed first at my program. And nothing more… I tried to use M1 and M2 instead of M3 and M4. The result is the same.
The interesting notice: if I commented rows that describe any ONE motor, another motor works properly!!!
More over, if I not use serial port and program commands all motions in cycle loop(), then BOTH motors work very good!
So, I’m sure that Arduino, MotorShild and two motors are well. But it is something wrong in my program. I have tested a lot of variants - it was in vain :frowning:
I suppose that my mistake is connected with wrong handling of serial data. So, please, give me advice where to dig.
Many Thanks.

  if (Val == 119) // w

Do you promise to keep the comments always up to date? I doubt that will happen. There really is no need to have them at all. if(Val == 'w') works just as well, and no comments are needed, and there is no need to consult an ASCII table.

    lMotor.run(FORWARD);    // if I comment this row...
    lMotor.setSpeed(spd);     //... this row...
    rMotor.run(FORWARD);
    rMotor.setSpeed(spd);

Shouldn't you set the speed first, then put it in gear?

There are jumpers on that shield, IIRC. How are they set?

I wasn't aware that the Adafruit motor library was compatible with the Arduino motor shield. I didn't think the pins used were the same.

Make sure your power supply is capable of driving two motors. Replace the motor's with LEDs if that works then the code is fine and it is the interference caused by the motors that is stopping it working, add more supply decoupling.

Thank You very much! It works perfectly now! If the battery were good, my program wouldn't reset Arduino after pressing any button but 's'. So, many thanks for all!