rc car control rf code help

one motor controls steering and one for forward reverse my current code only lets me do one thing at a time f,b,left,right i of course would like to move and steer at the same time ill post my tx and rx side code

int SW1 = 8; //forward
int SW2 = 9; //backward
int SW3 = 3; //left
int SW4 = 2; //right
//int SW5 = ; //lights

void setup()
{
  pinMode(SW1, INPUT_PULLUP);
  pinMode(SW2, INPUT_PULLUP);
  pinMode(SW3, INPUT_PULLUP);
  pinMode(SW4, INPUT_PULLUP);
  
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  Serial.begin(9600);
}
void loop(void)
{
  unsigned char i=0;
  
  //backward
  if ( digitalRead(SW1) == HIGH)
  {
    (i = 1);
    Serial.println("Backward");
  }
  //forward
else if ( digitalRead(SW2) == HIGH)
  {
    (i = 2);
    Serial.println("Forward");
  }
  //left
 else if ( digitalRead(SW3) == HIGH)
   {
     (i = 3);
   Serial.println("Left");
   }
   //right
   else if ( digitalRead(SW4) == HIGH)
   {
     (i = 4);
   Serial.println("Right");
   }
  else 
  {
    (i = 5);
  }
    
    send_data(i);
    Serial.print("i=");
    Serial.println(i,DEC);
    delay(500);
    send_data(0);
    

  }
//====================================
void send_data(unsigned char data)
{
  digitalWrite(4,(data&0x01));
  digitalWrite(5,(data&0x02));
  digitalWrite(6,(data&0x04));
  digitalWrite(7,(data&0x08));
}
#include <MotorDriver.h>
int data=0;

const int rx_led = 42;

void setup()
{
  motordriver.init();
  motordriver.setSpeed(200, MOTORB);
  motordriver.setSpeed(50, MOTORA);
  
   pinMode(rx_led, OUTPUT);
  digitalWrite(rx_led, LOW);
  
  pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(5,INPUT);
  pinMode(6,INPUT);
  pinMode(7,INPUT);
  attachInterrupt(1,RF_VT,RISING);
  Serial.begin(9600);
}
void loop()
{
  //direction
    if (data == 2)
    {
      digitalWrite(rx_led, HIGH);
      motordriver.goForward();
    }
    else if (data == 1)
    {
      digitalWrite(rx_led, HIGH);
      motordriver.goBackward();
    }
    else if (data == 3)
    {
      digitalWrite(rx_led, HIGH);
      motordriver.goLeft();
    }
    else if (data == 4)
    {
      digitalWrite(rx_led, HIGH);
      motordriver.goRight();
    }
    else if(data == 5)   
    {
      digitalWrite(rx_led, LOW);
      motordriver.stop();
    }
    delay(50);
}

//=======================================
//=======================================
void RF_VT() // interrupt service function
{
  data=(digitalRead(4)<<3)+(digitalRead(5)<<2)+(digitalRead(6)<<1)+(digitalRead(7)<<0);
  Serial.print("data=");
  Serial.println(data,DEC);
}

You need to send more than the 4 cardinal values. If two switches are pressed,, you need to send a value that indicates that. Instead of the 1, 2, 3, and 4 you have now, those values should be 1, 2, 4, and 8. Look at the binary pattern for those numbers to see why.

Then, when two switches are pressed, add the values for the two switches. For instance if the 2nd and 3rd switch are pressed, you'd send 6 (2 + 4), to tell the receiver to turn left while moving forward. If the 1st and 4th switches are pressed, you'd send 9 (1 + 8), to turn right while backing up.

(Lose) (the) (useless) (parentheses) (around) (everything). Learn to use them only when needed.

Interrupt service routines are NOT the place to be doing Serial.print().

Variables shared between an ISR and non-interrupt functions, like loop(), need to be declared volatile.

do i need to keep the digitalRead or can i just word it like this

else if(SW1 == HIGH && SW3 == HIGH)
{
i=5;
}

do i need to keep the digitalRead or can i just word it like this

else if(SW1 == HIGH && SW3 == HIGH)
{

You gave SW1 the value 8.
Do you think that's ever going to equal HIGH (aka 1) ?

else if((digitalRead(SW1) == HIGH) && (digitalRead(SW3) == HIGH))
{
i=5;
}

i did update y code and it compiles good but is there an easier way then all the if statments?

int SW1 = 8; //forward
int SW2 = 9; //backward
int SW3 = 3; //left
int SW4 = 2; //right
//int SW5 = ; //lights

void setup()
{
  pinMode(SW1, INPUT_PULLUP);
  pinMode(SW2, INPUT_PULLUP);
  pinMode(SW3, INPUT_PULLUP);
  pinMode(SW4, INPUT_PULLUP);
  
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  Serial.begin(9600);
}
void loop(void)
{
  unsigned char i=0;
  
  //backward
  if ( digitalRead(SW1) == HIGH)
  {
    i = 1;
  }
  //forward
else if ( digitalRead(SW2) == HIGH)
  {
    i = 2;
  }
  //left
 else if ( digitalRead(SW3) == HIGH)
   {
     i = 4;
   }
   //right
   else if ( digitalRead(SW4) == HIGH)
   {
     i = 8;
   }
   //left back up
  else if((digitalRead(SW1) == HIGH) && (digitalRead(SW3) == HIGH))
  {
    i=5;
  }
  // right back up
  else if((digitalRead(SW1) == HIGH) && (digitalRead(SW4) == HIGH))
  {
    i=9;
  }
  //straight left
  else if((digitalRead(SW2) == HIGH) && (digitalRead(SW3) == HIGH))
  {
    i=6;
  }
  // straight right
  else if((digitalRead(SW2) == HIGH) && (digitalRead(SW4) == HIGH))
  {
    i=10;
  }
  //stop signal
  else
  {
    i =16 ;
  }
    send_data(i);
    Serial.print("i=");
    Serial.println(i,DEC);
    delay(500);
    send_data(0);
    

  }
//====================================
void send_data(unsigned char data)
{
  digitalWrite(4,(data&0x01));
  digitalWrite(5,(data&0x02));
  digitalWrite(6,(data&0x04));
  digitalWrite(7,(data&0x08));
}

i did update y code and it compiles good but is there an easier way then all the if statments?

Yes. The reason for using 1, 2, 4, and 8 as the values associated with the switches is so that you can simply add the value corresponding to a switch, if the switch is pressed.

int i = 0;
if(digitalRead(SW1) == HIGH)
  i += 1;

if(digitalRead(SW2) == HIGH)
  i += 2;

if(digitalRead(SW3) == HIGH)
  i += 4;

if(digitalRead(SW4) == HIGH)
  i += 8;

// Now send i

Look at what this code sets i to if only one switch is pressed. Look at what it sets i to if two (or more) switches are pressed.

oh i see so it just adds it together if two are pressed so say SW1 and SW3 are pressed i would only need to tell my RX side what to do if data value is 5?

i would only need to tell my RX side what to do if data value is 5?

Or 1 or 2 or 4 or 8 or 3 or 9 or any of the valid combinations. You can do the same in reverse on the receiver.

Subtract 8 or 4 or 2 or 1 until the value becomes 0 to know what to do.

Not understanding the subtracting part what number does it subtract from?

Not understanding the subtracting part what number does it subtract from?

The number you sent it. If you send it 5, you can see that it is not greater than or equal to 8, so the 8 action is not needed. It is greater than or equal to 4, so the 4 action is needed. Note that, and subtract 4, leaving 1. That value is not greater than or equal to 2, so the 2 action is not needed. The value is greater than or equal to 1, so the 1 action is needed. Note that, and subtract 1.

Now, perform the actions that you noted needed to be done - 4 and 1.

i under stand the concept but is there an example code i could see?

Try something.
Post it.

if (data >= 1)
{
digitalWrite(rx_led, HIGH);
motordriver.goBackward();
}
or maybe

unsigned char i = 0;

else if (data == 1)
{
i -=1;
digitalWrite(rx_led, HIGH);
motordriver.goBackward();
}

but i cant be 0 if im subtracting from it right? but then i isnt really doing anything with the data

You need to start with 8, then 4, then 2, then 1.

unsigned char i = 0;

 if (data == 1)
    {
      i -= 8;
      digitalWrite(rx_led, HIGH);
      motordriver.goBackward();
    }
    if (data == 2)
    {
      i -= 4;
      digitalWrite(rx_led, HIGH);
      motordriver.goForward();
    }
    if (data == 3)
    {
      i -= 2;
      digitalWrite(rx_led, HIGH);
      motordriver.goLeft();
    }
    if (data == 4)
    {
      i -= 1;
      digitalWrite(rx_led, HIGH);
      motordriver.goRight();
    }
    
    }

unsigned char i = 0; on my reciever side would this have to be the sum of all numbers sense im subtracting?

The value that you want to operate on, on the receiver, is held in data, not i.

 if (data == 1)
    {
      data -= 8;
      digitalWrite(rx_led, HIGH);
      motordriver.goBackward();
    }
    if (data == 2)
    {
      data -= 4;
      digitalWrite(rx_led, HIGH);
      motordriver.goForward();
    }
    if (data == 3)
    {
      data -= 2;
      digitalWrite(rx_led, HIGH);
      motordriver.goLeft();
    }
    if (data == 4)
    {
      data -= 1;
      digitalWrite(rx_led, HIGH);
      motordriver.goRight();
    }
    
    }