Introduction: RC Toy Car Using NRF24L01

About: Check out my YouTube channel, for similar projects.

We all love playing with RC toy cars. In this instructable, I will show you how I created a simple RC toy car using bunch of wheels, motors, arduino and nRF24L01.

We have two main components in any RC toy car namely Remote and Toy car. First we will create remote following that we will get into details of toy car.

Let's get started.

Step 1: Video

Have a look at small comprehensive video describing all steps needed to create RC toy car.

Video does not contain explanation on nRF's working which I will cover later in this instructable.

Step 2: Remote's Hardware

Description: Remote allows player to control motion of toy car. My remote consist of three parts. 3.3V arduino pro mini, nRF24L01 and four push buttons. Arduino reads status of push buttons and transmit it using nRF24L01 connected on its SPI interface. Attached schematic shows connection between different parts of remote.

Components:

  • 3.3V arduino pro mini
  • nRF24L01
  • 4 push buttons
  • Breadboard
  • Male jumper wires

P.S. you will need FTDI USB to serial converter to program arduino pro mini.

Step 3: Remote's Software (arduino Code)

Description:Like its hardware, remote's software also consist of three parts. Variable initialization, setup and loop.

Variable initialization:Variable initialization includes specifying nRF's CE and CSN pin connection to arduino along with address to be used by RF pipe formed between remote and toy car. Variable initialization also includes pin allocation for push buttons.

#include <SPI.h>
#include <RF24.h>

RF24 radio(7,8);
const byte address[6] = "00001";

const int frontButton = 6; //pressing button moves toy car forward
const int backButton = 5;  //pressing button moves toy car backward
const int leftButton = 4;  //pressing button moves toy car to left
const int rightButton = 3; //pressing button moves toy car to right</p>

Setup: In setup part, First we set pinMode of all push buttons to INPUT_PULLUP avoiding use of external resistors. Following pinMode is nRF radio's initialization.

void setup() {
     // put your setup code here, to run once:
      pinMode(frontButton,INPUT_PULLUP);
      pinMode(backButton,INPUT_PULLUP);
      pinMode(leftButton,INPUT_PULLUP);
      pinMode(rightButton,INPUT_PULLUP);
      Serial.begin(9600);

      radio.begin();
      Serial.println("checking if chip connected");
      bool check = radio.isChipConnected();
      Serial.print("check-");
      Serial.println(check);
  
      radio.openWritingPipe(address);
      radio.setPALevel(RF24_PA_HIGH);
      radio.stopListening();
}

Loop: In loop part we read state of four pushbuttons, form an integer array and transmit it. This process repeats every 100ms (you can play with this number).

void loop() {

      // put your main code here, to run repeatedly:
      int message[4];
      
      message[0] = digitalRead(frontButton);
      message[1] = digitalRead(backButton);
      message[2] = digitalRead(leftButton);
      message[3] = digitalRead(rightButton);
      //int i;
      //for (i = 0; i < 4; i = i + 1) {
      //      Serial.print(message[i]);
      //}
      Serial.println("Transmitted");
      radio.write(&message,sizeof(message));
      delay(100);       //You can play with this number
}

Step 4: What Is NRF24L01?

Description: Before we proceed to construction of toy car, lets talk about nRF24L01. It is a single chip transciver operation in 2.4GHz ISM band. Its supply voltage range from 1.9 to 3.6V. It consumes 11.3mA TX at 0dbm output power and 13.5mA RX at 2Mbps air data rate. It has four different transmission power settings and three different data rate settings. It uses SPI as communication interface to micro-controllers. Breakout boards of nRF24L01 available in market contain 8 pins which segregates to 2 supply pins, 4 SPI pins, 1 chip enable and 1 interrupt pin as shown in attached image.

Also attaching a video on how you can create simple wireless link using nRF24L01.

Step 5: Toy Car's Hardware

Description:Its mechanical hardware consist of chassis made out of acrylic sheet and components assembled on it using M3 nut/bolts which includes a universal wheel, two plastic wheels and two geared DC motor. On electronic side we have 3.3V arduino pro mini, nRF24L01 and 3.3V regulator assembled on a PCB. To drive motors I am using L293D motor driver. Four AA cells make power source for toy car.

Components:

  • DIY robot car chassis kit (this includes chassis, universal wheel, 2 plastic wheels and geared DC motors),
  • M3 nuts and bolts,
  • 3.3V arduino pro mini,
  • nRF24L01,
  • 3.3V regulator,
  • L293D motor driver module,
  • 4 AA cells and holder.

Attached schematic shows all connections of toy car.

Let's take a look at L293D in next step.

Step 6: What Is L293D?

Description: L293D is a quadruple half-H bridge driver. With proper data inputs each pair of drivers form a full-H bridge reversible drive suitable for motor applications. Pin diagram and functional table of L293D is attached in images, if EN is set to high output follows A pin. Functional block diagram is also attached. I used arrangement shown on left in toy car.

Step 7: Toy Car's Software

Description: Like remote's arduino code, toy car's arduino code is also divided in three parts. Variable initialization, setup and loop.

Variable Initialization: It includes nRF radio's setup identical to that of remote's radio. We also define arduino pins that connects to L293D motor driver in this segment.

<p>#include <SPI.h><spi.h><br>#include <RF24.h><rf24.h></rf24.h></spi.h></p><p>RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";</p><p>//Motor1 is controlled by IN1 and IN2
//Motor2 is controlled by IN3 and IN4
const int IN1 = 6;
const int IN2 = 5;
const int IN3 = 4;
const int IN4 = 3;</p>

Setup: We set pins that connects to L293D as output followed by startup code for nRf24L01.

<p>void setup() {<br>      pinMode(IN1,OUTPUT);
      pinMode(IN2,OUTPUT);
      pinMode(IN3,OUTPUT);
      pinMode(IN4,OUTPUT);
      Serial.begin(9600);
      
      radio.begin();
      Serial.println("checking if chip connected");
      bool check = radio.isChipConnected();
      Serial.print("check-");
      Serial.println(check);
      
      radio.openReadingPipe(0, address);
      radio.setPALevel(RF24_PA_MIN);
      radio.startListening();
}</p>

Loop: We wait for availability of an integer array of size 4. On reception of this array we activate appropriate output pins depending on which button was pressed on remote.

void loop {
<p>Serial.println();<br>            int sum = message[0]+message[1]+message[2]+message[3];
            if (sum==4) {
                  //stop
                  digitalWrite(IN1,LOW);
                  digitalWrite(IN2,LOW);
                  digitalWrite(IN3,LOW);
                  digitalWrite(IN4,LOW);
                  Serial.println("LLLL");                  
            }
            if (sum==3) {
                  if (message[0]==0 && message[1]==1 && message[2]==1 && message[3]==1) {
                        //move forward
                        digitalWrite(IN1,HIGH);
                        digitalWrite(IN2,LOW);
                        digitalWrite(IN3,LOW);
                        digitalWrite(IN4,HIGH);
                        Serial.println("HLLH");
                  }
                  if (message[0]==1 && message[1]==0 && message[2]==1 && message[3]==1) {
                        //move backward
                        digitalWrite(IN1,LOW);
                        digitalWrite(IN2,HIGH);
                        digitalWrite(IN3,HIGH);
                        digitalWrite(IN4,LOW);
                        Serial.println("LHHL");
                  }
                  if (message[0]==1 && message[1]==1 && message[2]==0 && message[3]==1) {
                        //move forward
                        digitalWrite(IN1,LOW);
                        digitalWrite(IN2,LOW);
                        digitalWrite(IN3,LOW);
                        digitalWrite(IN4,HIGH);
                        Serial.println("LLLH");
                  }
                  if (message[0]==1 && message[1]==1 && message[2]==1 && message[3]==0) {
                        //move left
                        digitalWrite(IN1,HIGH);
                        digitalWrite(IN2,LOW);
                        digitalWrite(IN3,LOW);
                        digitalWrite(IN4,LOW);
                        Serial.println("HLLL");
                  }
            }
            if (sum<=2) {
                  //stop
                  digitalWrite(IN1,LOW);
                  digitalWrite(IN2,LOW);
                  digitalWrite(IN3,LOW);
                  digitalWrite(IN4,LOW);
                  Serial.println("LLLL");
            }
      }
</p>} 

That's it folks. Thanks for reading. Vote if you liked it.

Let me now if you make a toy car of your own. Thanks again.

Arduino Contest 2017

Participated in the
Arduino Contest 2017

Wheels Contest 2017

Participated in the
Wheels Contest 2017

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017