How to Combine Radio Control and Arduino for Dual Control of an RC Car

Hello, good morning Arduino community,

It's been a while since I last checked in here, but I’ve finally made progress with programming Arduino and, along the way, the ESP32. I’ve managed to learn the basics of electronics. At the moment, I’ve created a small electric car as a test project, which I control using my mobile phone. I’ve set up sliders for the servo, another for the motor, and some LEDs for the lights. As we know, once you get the hang of basic programming, the code becomes fairly simple.

At first, I used the traditional 9G SG90 micro servo from AliExpress. However, for convenience, I’ve now mounted an RC car with a Radio Link system, using more powerful 40kg and 80kg servos. Essentially, it’s an RC car controlled by a radio transmitter. Thanks to my early work with Arduino, I’ve been able to create something pretty interesting without any issues. But now, I’d like to take things a step further.

My question arises after watching some YouTube videos where people control their devices using both a radio controller and Arduino, like in the case of autonomous boats. Controlling Arduino separately seems straightforward, but I’m unsure how to connect both systems. I’d like to be able to switch between controlling the car via radio control and via Arduino.

For example, when using the radio control, I simply connect the servo to the receiver, which is connected to the ESC, the motor, and the battery. But I’m not sure how to use Arduino as a "second controller." The programming itself isn’t the issue, as I can already control the car via mobile using Arduino. However, I don’t understand how to connect the servo and motor so that they can alternate between being controlled by the radio transmitter and Arduino.

I could start experimenting, but I thought it’d be a good idea to ask the community, as someone might have already tried something similar. I’m really happy with what I’ve accomplished so far, but there’s always more to learn. The possibilities are endless, and I’ve got many ideas. I’d love to hear your opinions on the best way to approach this. The idea I have about how to wire things together seems a bit complicated, but I’m sure there’s a simpler way.

So far, I’ve managed to individually control the RC car using either a radio transmitter or Arduino, and both methods work well. But I’ve been thinking all week about how to merge the two systems. I’m even considering building an autonomous boat in the future, but for now, I’m experimenting with the RC car.

Sometimes this all feels a bit crazy since even small changes can lead to new learning experiences. For example, switching from traditional Bluetooth to BLE has been an interesting improvement.
Thanks in advance for your help, and best regards to everyone!

Topic moved. Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.

Thanks, it's been a while since I last logged in :saluting_face:Best regards!

We know, we can see that :smiley:

I think using the Arduino to monitor the RC receiver channel outputs and the phone connection with program instructions on how to handle both inputs would be a way to go. Have the Arduino calculate the PWM receiver outputs and act accordingly. If the phone app connection fails, just use the receiver values. When both are present, you may pick one as primary or instruct the device to somehow consider both inputs to command the RC vehicle.

It's a good idea, but my main concern is with the wiring, particularly for the servo motor. Since the Arduino won't be controlling the servo directly, I could try something... In theory, the servo will already be connected to the radio receiver module.....The Arduino would have to read the servo's position and then create an output to control it. The simplest approach would be to have the Arduino act like a radio receiver module, but what I would really like to achieve is an independent system both working in the real time. I’m wondering if this would be possible.
For example, can be simple like a drone, although I've never seen a consumer drone with a backup system, military drones surely have one. My question is how to wire the servo to the Arduino if it's already connected to the radio receiver. I suppose I'd need to create a library for that...but thanks for idea, I 'm going to work on this possibility.

Note in advance: be aware of signal levels.

You can route the signal from the Radio Link receiver to the ESP32 instead of to the servo. The ESP32 can then either duplicate that signal on an output to control the servo or it can send its own signal to the servo. I'm not sure how easy duplication will be.

Alternatively, you can use some logic gates to block the signal from the receiver and add some more logic to route the ESP32 signal to the servo.

1 Like

During the Corona pandemic I created a wireless Buddybox system to be able to continue giving modelflying lessons, without the need for teacher and student to stay in close proximity to eachother.

Both student and teacher have their own transmitter and in the RC aircraft 2 PPM receivers were connected to one Arduino (promini). The teacher could command via Channel 8 in the PPM stream if student or teacher are in control of the airplane. The arduino then listens to the selected PPM receiver and turns the first 6 PPM channels into 6 different PWM servo outputs.

Here is the sketch:

/*
 * Arduino as Wirless Buddybox RC switch
 * https://youtu.be/ZxOkK0N1Gtw
 * reads two CPPM receivers connected to digital pins 2 (teacher) and 3 (student)
 * Outputs 6 PWN servo channels on digital pins 4-9
 * CPPM Channel 8 (teacher) defines if servo PWM outputs channels 1-4 (pins 4-7) come from teacher or student. If teacher LED goes on.
 * Channel 5-6 (pin 8-9) always come from teacher
 * 
 * V1 Hans Meijdam, Jan 2021
 * V1.1 Hans Meijdam, Jan 2021 should now compile on any standard Arduino IDE environment.
 */

#define RC_CHANS            8
volatile uint16_t rcValue_A[RC_CHANS] = {1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500}; // interval [1000;2000]
volatile uint16_t rcValue_B[RC_CHANS] = {1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500}; // interval [1000;2000]

#include <Servo.h> // If you get a "not found" compilation error here. The servo library can be added via the Arduino IDE library manager, if not already standard included these days.
// you can change the 6 Servo PWM output pins, but not the 2 CMMP input pin numbers 2 and 3 (see below)
#define SERVO1_PIN              4
#define SERVO2_PIN              5
#define SERVO3_PIN              6
#define SERVO4_PIN              7
#define SERVO5_PIN              8
#define SERVO6_PIN              9

#define NEUTRAL_US              1500 /* Default position in case of no pulse at startup */
#define NOW                     1

enum {AILERON = 0, ELEVATOR, THROTTLE, RUDDER, AUX1, AUX2, SERVO_NB}; /* Define servo's index AND the amount of servos */
Servo ServoMotor[SERVO_NB]; /* Table Creation for all servo objects */

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_BUILTIN, OUTPUT); // led wil turn on when teacher controls servos.
  ServoMotor[AILERON].attach(SERVO1_PIN); //I use AETR servo order, but you can change as you like
  ServoMotor[ELEVATOR].attach(SERVO2_PIN);
  ServoMotor[THROTTLE].attach(SERVO3_PIN);
  ServoMotor[RUDDER].attach(SERVO4_PIN);
  ServoMotor[AUX1].attach(SERVO5_PIN);
  ServoMotor[AUX2].attach(SERVO6_PIN);
  // note that the external interrupts on Arduino based on atmega 328/168 can only be on pin 2 and 3. don't change these
  attachInterrupt(digitalPinToInterrupt(2), rxInt_A, RISING); //Arduino PIN 2 (PD2, INT0)
  attachInterrupt(digitalPinToInterrupt(3), rxInt_B, RISING); //Arduino PIN 3 (PD3, INT1)
}

void loop() {
  if (rcValue_A[7] < 1300) {
    digitalWrite(LED_BUILTIN, HIGH);
    ServoMotor[AILERON].writeMicroseconds(rcValue_A[0]);
    ServoMotor[ELEVATOR].writeMicroseconds(rcValue_A[1]);
    ServoMotor[THROTTLE].writeMicroseconds(rcValue_A[2]);
    ServoMotor[RUDDER].writeMicroseconds(rcValue_A[3]);
  }
  else {
    digitalWrite(LED_BUILTIN, LOW);
    ServoMotor[AILERON].writeMicroseconds(rcValue_B[0]);
    ServoMotor[ELEVATOR].writeMicroseconds(rcValue_B[1]);
    ServoMotor[THROTTLE].writeMicroseconds(rcValue_B[2]);
    ServoMotor[RUDDER].writeMicroseconds(rcValue_B[3]);
  }
    ServoMotor[AUX1].writeMicroseconds(rcValue_A[4]);
    ServoMotor[AUX2].writeMicroseconds(rcValue_A[5]);
}

/**************************************************************************************/
/***************                PPM SUM RX Pins reading            ********************/
/**************************************************************************************/
void rxInt_A(void) {
  uint16_t now_A, diff_A;
  static uint16_t last_A = 0;
  static uint8_t chan_A = 0;
  now_A = micros();
  sei();
  diff_A = now_A - last_A;
  last_A = now_A;
  if (diff_A > 3000) chan_A = 0;
  else {
    if (900 < diff_A && diff_A < 2200 && chan_A < RC_CHANS ) { //Only if the signal is between these values it is valid, otherwise the failsafe counter should move up
      rcValue_A[chan_A] = diff_A;
    }
    chan_A++;
  }
}

void rxInt_B(void) {
  uint16_t now_B, diff_B;
  static uint16_t last_B = 0;
  static uint8_t chan_B = 0;
  now_B = micros();
  sei();
  diff_B = now_B - last_B;
  last_B = now_B;
  if (diff_B > 3000) chan_B = 0;
  else {
    if (900 < diff_B && diff_B < 2200 && chan_B < RC_CHANS ) { //Only if the signal is between these values it is valid, otherwise the failsafe counter should move up
      rcValue_B[chan_B] = diff_B;
    }
    chan_B++;
  }
}

and a small demo video:

(I think some Radiolink receivers can output a PPM stream on their Ch8 pin.)

2 Likes

That’s very cool and interesting! Thanks a lot! This gives me new ideas. :slight_smile:

I believe the answer to this specific question is “No”. The servo control wire will not work with two different controllers wired together. I believe that wiring the receiver channel output and the Arduino channel PWM output together will likely damage one or both devices when they fight each other over whether the output is high or low.

There is not a simple electrical circuit that will accept 2 PWM inputs out of phase and generate a single valid output PWM signal. So, I believe you must choose between the two servo controlling systems and connect the other system to inputs on the system with direct control of the servo. The RC receiver module only has the RF antenna input and no ability to operate with conflicting input signals. The Arduino module does have this capability and may be programmed to operate within your instructions. So, I just repeated my previous post with a new wording.

1 Like

Thanks :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.