Project tutorial
RC Toy Car Using nRF24L01

RC Toy Car Using nRF24L01 © GPL3+

We all love playing with RC toy cars. In this mini project let's create an RC toy car using a bunch of wheels, motors, Arduino & nRF24L01.

  • 3,892 views
  • 0 comments
  • 9 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

We all love playing with RC toy cars. In this mini project 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.

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.

Step 1: 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 2: 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.
  • 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.
  • 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).

You can find code in code section.

Step 3: 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 4: Toy Car's Hardware

Description: It's 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 5: 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 6: 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.
  • Setup: We set pins that connects to L293D as output followed by startup code for nRf24L01.
  • 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.

Code is available in code section

That's it folks. Thanks for reading.

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

Code

Remote Arduino
#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

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();
}

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
}
Toy carArduino
#include <SPI.h>
#include <RF24.h>

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

//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;

void setup() {
      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();
}
void loop() {
      if (radio.available()) {
            int message[4];
            radio.read(&message, sizeof(message));
            int i;
            for (i = 0; i < 4; i = i + 1) {
                  Serial.print(message[i]);
            }
            Serial.println();
            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");
            }
      }
}

Schematics

remote
2 2 r6hh7pgcao
toy car
7 3 xk9lc3mqda

Comments

Similar projects you might like

Turn your RC Car to Bluetooth RC car

Project tutorial by Prajjwal Nag

  • 11,967 views
  • 1 comment
  • 11 respects

Arduino 4WD RC Car

Project tutorial by Andriy Baranov

  • 13,133 views
  • 3 comments
  • 43 respects

Wi-Fi RC Car - Qi Enabled

Project tutorial by Ioannis Kydonis

  • 10,192 views
  • 6 comments
  • 32 respects

RC Car to BT Car Controlled with Blynk

Project tutorial by Team Daxes Hacks

  • 3,598 views
  • 2 comments
  • 6 respects

Android Arduino RC Car

Project tutorial by RAFI RASHEED T C

  • 15,340 views
  • 2 comments
  • 38 respects

RC Rover Controlled by Gest

Project showcase by Salim Khazem

  • 993 views
  • 1 comment
  • 12 respects
Add projectSign up / Login