Two Arduinos an RC Monster truck and a 4channel long range link

Hi

Thanx for the quick reply

I started by building a small Tracked rover controlled by an Arduino Mini (picture attached below)
along with a Remote control powered by an Arduino UNO R3 and a Joystick shield, the 433MHz RC link that i used had only 1 data channed so Virtual wire & EasyTransferVirtualWire was the best suited for my needs, it worked perfectly.

After i had this working for a while i decided to add an LCD screen, since i had an LCD shield already i used that
i connected the remote control to the LCD shield+Arduino using Easy Transfer for starters over Serial port, and it worked nicely

so after that was all working (seperately) i decided to stick it all together with the Monster truck, added the motor shield, receiver and Arduino and uploaded VirtualWire and EasyTransferVirtualWire and Viola, it worked as well :slight_smile: so far so good...

and then i wanted to add a Servo... and everything started going wrong

so this is my most basic problem/question:
"how do i talk to a servo over RC control?"

See because with my first RF link with only one data line i could only use Virtual wire so that the information is wrapped up and sent at once.
Now i have an long range RF link with 4Channels so i was wondering if there might be a direct and dirty approach like such: Arduino-->4 TX pins-->Transmitter------------>>--------Receiver-->4RX pins-->Arduino
so that i whatever is written onto the TX pins is just spat out the other end without any delays, then the receiver can figure out the data...

i tried the following:
TX Code

char Sw1=8, Sw2=7, Sw3=A7, Sw4=A5, Sw5=12, Sw6=10;

  int X2;      //Right Joystick
  int Y1;      //Left Joystick
  int S1;      //Switch 1
  int S5;      //Switch 5
  
void setup()
{
  Serial.begin(9600);
  
  pinMode(A0, INPUT);      //X1
  pinMode(A1, INPUT);      //X2
  pinMode(A2, INPUT);      //Y1
  pinMode(A3, INPUT);      //Y2

  pinMode(3, OUTPUT);      //Set the Long Range TX Pin 3 as an output
  digitalWrite(3, HIGH);
  pinMode(5, OUTPUT);      //Set the Long Range TX Pin 2 as an output
  digitalWrite(5, HIGH);
  pinMode(6, OUTPUT);      //Set the Long Range TX Pin 1 as an output
  digitalWrite(6, HIGH);
  pinMode(9, OUTPUT);      //Set the Long Range TX Pin 0 as an output
  digitalWrite(9, HIGH);
  
  pinMode(Sw1, INPUT);      //Switch 1
  digitalWrite(8, HIGH);
  pinMode(Sw2, INPUT);      //Switch 2
  digitalWrite(7, HIGH);
  pinMode(Sw3, INPUT);      //Switch 3
  digitalWrite(A7, HIGH);
  pinMode(Sw4, INPUT);      //Switch 4
  digitalWrite(A5, HIGH);
  pinMode(Sw5, INPUT);      //Switch 5
  digitalWrite(12, HIGH);
  pinMode(Sw6, INPUT);      //Switch 6
  digitalWrite(10, HIGH);
  
  pinMode(4, OUTPUT);      //LED TX1
  digitalWrite(4, LOW);
  pinMode(2, OUTPUT);      //LED TX2
  digitalWrite(2, LOW);
  pinMode(13, OUTPUT);      //LED TX3
  digitalWrite(13, LOW);
  
}

void loop()
{
  X2 = analogRead(A1);
  Y1 = analogRead(A3);
  S1 = digitalRead(Sw1);
  S5 = digitalRead(Sw5);
      
  Serial.print(X2);
  Serial.print("  ");     
  Serial.print(Y1);
  Serial.print("  ");
  
  Serial.print(S1);
  Serial.print("  ");
  Serial.print(S5);
  Serial.print("  ");
  
  analogWrite(3, X2);      //D3 Transmitter pin
  analogWrite(5, Y1);      //D2 Transmitter pin
  digitalWrite(6, S1);      //D1 Transmitter pin
  digitalWrite(9, S5);      //D0 Transmitter pin
  
  digitalWrite(4, HIGH);
      digitalWrite(2, LOW);
      digitalWrite(13, LOW);
      delay(60);
      digitalWrite(4, LOW);
      digitalWrite(2, HIGH);
      digitalWrite(13, LOW);
      delay(60);
      digitalWrite(4, LOW);
      digitalWrite(2, LOW);
      digitalWrite(13, HIGH);
      delay(60);
      digitalWrite(4, LOW);
      digitalWrite(2, LOW);
      digitalWrite(13, LOW);
      delay(100);
  
}

RX Code

int X2;      //Right Joystick
  int Y1;      //Left Joystick
  int S1;      //Switch 1
  int S5;      //Switch 5
  
  int direction= 397;
  int steering= 361;
  int val = 0;
  int lights = 0;
  int drive = 0;

void setup()
{
  Serial.begin(9600);
  
  pinMode(2, OUTPUT);      //Lights
  pinMode(3, OUTPUT);      //Lights
  pinMode(10, OUTPUT);      //Lights
  pinMode(13, OUTPUT);      //Lights
  
  pinMode(1, INPUT);      //Lights D0
  pinMode(0, INPUT);      //Drive D1
  pinMode(A4, INPUT);      //D2 
  pinMode(A5, INPUT);      //D3 
  
}

void loop()
{
  X2 = analogRead(A5);      //D3
  Y1 = analogRead(A4);      //D2
  S1 = digitalRead(0);      //D1
  S5 = digitalRead(1);      //D0
  
  direction = Y1;    // FWD/REV
  steering = X2;   //CW/CCW
  lights = S1;
  drive = S5;
  
  Serial.print("  ");     
  Serial.print(X2);
  Serial.print("  ");
  Serial.print(Y1);
  Serial.print("  ");
  
  Serial.print(S1);
  Serial.print("  ");
  Serial.print(S5);
  Serial.print("  ");
  
    if (lights == 1){
    Serial.println("On");
    digitalWrite(2, HIGH);      //Lights
    digitalWrite(3, HIGH);      //Lights
    digitalWrite(10, HIGH);      //Lights
    digitalWrite(13, HIGH);      //Lights
  }
  
  if (lights == 0){
    Serial.println("Off");
    digitalWrite(2, LOW);      //Lights
    digitalWrite(3, LOW);      //Lights
    digitalWrite(10, LOW);      //Lights
    digitalWrite(13, LOW);      //Lights
    }
}

Nice try but it doesn't work.

So having had so much success untill now and facing this small but significant problem with RF and a servo, any advice on what approach to take further?

Thanking you in advance for the help :slight_smile:

Best Regards
Renier