code modification help

hi all . i have a code tat i got from a site . i need to add some more command to it .and i need some help

the code

int mA1 = 8;
int mA2 = 9;
int mB1 = 10;
int mB2 = 11;


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

  pinMode(mA1, OUTPUT);
  pinMode(mA2, OUTPUT);
  pinMode(mB1, OUTPUT);
  pinMode(mB2, OUTPUT);
}


void loop(){
  if (Serial.available() > 0) {
  char motors = Serial.read(); 
   switch(motors) {
    case 'R':
        digitalWrite(mA1,LOW);
        digitalWrite(mA2,HIGH);
        digitalWrite(mB1,LOW);
        digitalWrite(mB2,HIGH);
     break;
    case 'L':
        digitalWrite(mA1,HIGH);
        digitalWrite(mA2,LOW);
        digitalWrite(mB1,HIGH);
        digitalWrite(mB2,LOW);
     break;
    case 'U':
        digitalWrite(mA1,LOW);
        digitalWrite(mA2,HIGH);
        digitalWrite(mB1,HIGH);
        digitalWrite(mB2,LOW);
     break;
    case 'D':
        digitalWrite(mA1,HIGH);
        digitalWrite(mA2,LOW);
        digitalWrite(mB1,LOW);
        digitalWrite(mB2,HIGH);
     break;
   case 'C':
        digitalWrite(mA1,LOW);
        digitalWrite(mA2,LOW);
        digitalWrite(mB1,LOW);
        digitalWrite(mB2,LOW);
      break;
   }  
  }
}

i want to add letter A , B for headlights , horns

thanks in advance

And which pins are these additional devices attached to, and how should they behave?

i want to connect a buzzer and some bright LED with a transistor or a relay

to any pin 7 to 3

And the second part of the question?

at the moment there is no devise attached arduino there than 2 motor to drive it .

How are the buzzer and the lights supposed to behave?
Attaching them is simple.

ok went sending letter A the buzzer should buzz 1 second delay and went sending letter B the LED must stay on.

So, you already know how to set the pin modes for the these, so now you need to look at the blink without delay example to see how to turn the buzzer off after one second (1000 milliseconds).

is this right see at the bottom

int mA1 = 8;
int mA2 = 9;
int mB1 = 10;
int mB2 = 11;


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

  pinMode(mA1, OUTPUT);
  pinMode(mA2, OUTPUT);
  pinMode(mB1, OUTPUT);
  pinMode(mB2, OUTPUT);
  pinMode(13, OUTPUT);   
}


void loop(){
  if (Serial.available() > 0) {
  char motors = Serial.read(); 
   switch(motors) {
    case 'R':
        digitalWrite(mA1,LOW);
        digitalWrite(mA2,HIGH);
        digitalWrite(mB1,LOW);
        digitalWrite(mB2,HIGH);
     break;
    case 'L':
        digitalWrite(mA1,HIGH);
        digitalWrite(mA2,LOW);
        digitalWrite(mB1,HIGH);
        digitalWrite(mB2,LOW);
     break;
    case 'U':
        digitalWrite(mA1,LOW);
        digitalWrite(mA2,HIGH);
        digitalWrite(mB1,HIGH);
        digitalWrite(mB2,LOW);
     break;
    case 'D':
        digitalWrite(mA1,HIGH);
        digitalWrite(mA2,LOW);
        digitalWrite(mB1,LOW);
        digitalWrite(mB2,HIGH);
     break;
   case 'C':
        digitalWrite(mA1,LOW);
        digitalWrite(mA2,LOW);
        digitalWrite(mB1,LOW);
        digitalWrite(mB2,LOW);
      break;
       
    case 'A':
        digitalWrite(13, HIGH);
      
   }  
  }
}

Well, for safety, I'd add a break, but yes.
What does your testing show?

I will give it test asap . And tell u the result

when i sending "X and Y" the led works . on and off
but when i sending "H" even though i gave a delay of 1000 milliseconds it stays on .

i tried with and without break

int mA1 = 8;
int mA2 = 9;
int mB1 = 10;
int mB2 = 11;


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

  pinMode(mA1, OUTPUT);
  pinMode(mA2, OUTPUT);
  pinMode(mB1, OUTPUT);
  pinMode(mB2, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(13, OUTPUT);
}


void loop(){
  if (Serial.available() > 0) {
    char motors = Serial.read(); 
    switch(motors) {
    case 'R':
      digitalWrite(mA1,LOW);
      digitalWrite(mA2,HIGH);
      digitalWrite(mB1,LOW);
      digitalWrite(mB2,HIGH);
      break;
    case 'L':
      digitalWrite(mA1,HIGH);
      digitalWrite(mA2,LOW);
      digitalWrite(mB1,HIGH);
      digitalWrite(mB2,LOW);
      break;
    case 'F':
      digitalWrite(mA1,LOW);
      digitalWrite(mA2,HIGH);
      digitalWrite(mB1,HIGH);
      digitalWrite(mB2,LOW);
      break;
    case 'B':
      digitalWrite(mA1,HIGH);
      digitalWrite(mA2,LOW);
      digitalWrite(mB1,LOW);
      digitalWrite(mB2,HIGH);
      break;
    case 'S':
      digitalWrite(mA1,LOW);
      digitalWrite(mA2,LOW);
      digitalWrite(mB1,LOW);
      digitalWrite(mB2,LOW);
      break;
    case 'X':
      digitalWrite(2,HIGH);
      break;
    case 'Z':
      digitalWrite(2, LOW); 
      break;
    case 'H':
      digitalWrite(13, HIGH);
      delay(1000);

    }  
  }
}

it stays on

Probably because you didn't switch it off.

Also, have another read of reply #7

but i gave a delay 1000

it for a buzzer

but i gave a delay 1000

Yes, you delayed the loop by one second. (delayed, as in made it unresponsive for a whole second)
But you didn't turn the pin off.

But you didn't turn the pin off.

how do i do tat

sorry for my lack of knowledge in coding

Like most digital operations, it is the opposite of turning it on, which you did just before the delay

so should i do this

case 'H':
        digitalWrite(13, HIGH);
        delay(1000);
        digitalWrite(13, LOW);

That will turn it off after a second, yes, but it won't stop the "delay" making your loop unresponsive.
Suppose you've just turned on the horn, then notice you're about to slam into a wall.
The loop will not see your emergency stop command until a second later, which could be too late.

See reply #7

thanks

i got both work now.

next planing to add pan & tilt