Help me make my RC car wireless!

I have now build a RC car with a cabled controller. This is a full size RC car that we sit on and steer with a joystick module to arduino.

This is the code I use now

#include <SPI.h>
#include <Servo.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

// Hardware configuration
// Joystick Pins
int sensorPinX = A0;
int sensorPinY = A1;
int pwmOut = 6;
Servo myservo;
// Led Pins
int red = 4;
int green = 2;

RF24 radio(9,10);
const uint64_t pipes[1] = { 0xF0F0F0F0E1LL };
int sensorValueX = 0;  
int oldSensorValueX = 0; // to keep track of the X value
int sensorValueY = 0; 
int reposValue = 90; // default steady point for the servo
int inPin = 8;
int state = 0;
int reading;
int previous = 1;
long time = 0;
long debounce = 200;
int oldButtonState = LOW;
int x = 0;
int runcar = 0;
void setup(void)
  pinMode(inPin, INPUT);
    pinMode(pwmOut, OUTPUT);
void sendOrder()

  reading = digitalRead(inPin);
  if (reading == 1 && previous == 0 && millis() - time > debounce) {
    if (runcar == 0)
      runcar = 1;
      runcar = 0;

    time = millis();    
  previous = reading;

    if (runcar == 1) {
    sensorValueX = analogRead(sensorPinX);
    if(oldSensorValueX > 35 && oldSensorValueX < 1000)
      // If X axis is over the upper thresholds then we want to increment the value of the steady point of the servo
      if(sensorValueX > 1000)
      // If X axis is under the lower thresholds then we want to decrement the value of the steady point of the servo
      if(sensorValueX < 35)
    // we update the previous value of the X axis
    oldSensorValueX = sensorValueX;
    // Now we get the value of the Y axis
    // The Y axis is used to drive the servo
    sensorValueY = analogRead(sensorPinY);  
    // We have to map the Y value (from 0 to 1024) with the possible values for the servo (0 to 180)
    sensorValueY = map(sensorValueY,0,1020,0,180);
    sensorValueX = map(sensorValueX,1,1020,202,50);
    analogWrite(pwmOut, sensorValueX);
    if(sensorValueY > (reposValue -4) && sensorValueY < (reposValue+4)) sensorValueY = reposValue;
    } else {
    analogWrite(pwmOut, 0);
    } // else
} // void 
void loop(void)

I have taken this code from an other source on the Internet, I do not remember where.

I want to send Y: sensorValueY, X:sensorValueX and R:runcar to the receiver with NRF24 (transmitter)

I want to receive Y:sensorValueY X:sensorValueX R:runcar on the reciever. (NRF24)
Arduino who should read Y and set the servo, read X and set the speed, read R and decide to run the car or not.

I have just meet problems to try to make this wirelessly, I have tried to send both data to the device, but either I end up with an very unstable connection.

Can somebody please help me on my way? I have arduino uno and arduino micro.

Adding a nRF24L01+ object to your code does not make it wireless.

It seems your arduino is controlling the car, so you will need a second arduino with a second nRF24L01 to control it.

In this sketch you don't even initialize the nRF24L01, so there will be no sending or receiving.

I have just meet problems to try to make this wirelessly, I have tried to send both data to the device, but either I end up with an very unstable connection.

This is a lie, there never has been any connection with the above sketch.

I think you did misunderstood :slight_smile:

I have 2x NRF24 modules, and HAVE TRIED to use it, I can get connection between the two devices, and I can make them talk to each other. I have tried with the servo and with the engine. The problem is that I can see in the serial console from the receiver that the transmitter is not transmitting the signals as stable as it need to be.

BUT, the connection is so unstable and I have other issues, so I need help to customize the code to work with my needs ^^

Before I posted the code, I did remove everything with the radio to do, since I have uncommented everything and just use this code for one cabled controller :slight_smile:

Yes, I misunderstood.

I thought you were seeking help, not somebody who writes the code for you.

Do both of the radios have power supplies capable of providing at least 200mA? The 3v3 regulator on an Uno cannot. A 10uf cap across the radio supply pins can help.

With a mobile radio, a lot depends on the antenna type, obstacles that may come between the transmitter and receiver, and the power levels available. Apparently the units themselves can deliver at least 100 m. in clear line-of-sight configuration. I suggest you first test your links with the car static, at different distances. If you get some degree of instability, try dropping the data rate.

Another factor is that the higher the wavelength, the shorter the range. If you don't get what you want with these units, the little RFM22B's are 433 MHz. units, 200 mw. max, and excellent Rx sensitivity. There is a good RadioHead library for them. You can expect much better performance at the lower frequency, and they sell on Ebay for about $4, require one interrupt connection, and the SPI interface which is a built-in on most Arduino siblings. (pins 10, 11, 12, 13 on the Nano.)

From the looks of the NRF24, it has a built-in antenna, which is probably directional. For the RFM22B, you solder a 17 cm. wire to it, sticking straight up, and you get an omnidirectional antenna.


From what I understand you have a NRF24 on the car and a NRF24 on the remote control.

Can you please post a copy of both your circuits, the car circuit and the remote control circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Also the code for you RC arduino and your remote control arduino.

Thanks.. Tom.... :slight_smile:

I got my nRF24s working with this Tutorial

I suggest you use the TMRh20 version of the RF24 library - it solves some problems from the ManiacBug version

The pair of programs in this link may be useful.