top of page

Creating RC Car

In this tutorial, we will be looking at how to create a RC car. Be sure to check out my videos on NRF24L01 and L923D motor driver so that you can understand the making of this video better.


First of all, setup the circuit for RC Car and RC Controller as shown below :


RC Car Schematic


RC Car Controller

Then, upload the following code into RC Car and RC Controller receiver.


RC Car Code

 

// NRF24L01 UNO

// CE 7

// CSN 8

// SCK 13

// MOSI 11

// MISO 12


#include <SPI.h>

#include <nRF24L01.h>

#include <RF24.h>

#include <Servo.h>


RF24 radio(7, 8); // CE, CSN

Servo servo1;

int servo1_pin = 6;

const byte address[6] = "01010";

int joystick[2];

int xAxis, yAxis, servo_pos;


void setup() {

Serial.begin(115200);


servo1.attach (servo1_pin);

radio.begin();

radio.openReadingPipe(0, address);

radio.setPALevel(RF24_PA_MAX);

radio.startListening();

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

}


void loop() {


while (radio.available() ) {

radio.read( joystick, sizeof(joystick) );

xAxis = joystick[0];

yAxis = joystick[1];

Serial.println(joystick[0]);

servo_pos = map(xAxis,0,1023,0,180);

servo1.write (servo_pos);

if (yAxis < 600 && yAxis > 400)

{

digitalWrite(2, LOW);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

digitalWrite(5, LOW);

}


if (yAxis < 400 )

{

digitalWrite(2, LOW);

digitalWrite(3, HIGH);

digitalWrite(4, LOW);

digitalWrite(5, HIGH);

}


if (yAxis > 600 )

{

digitalWrite(2, HIGH);

digitalWrite(3, LOW);

digitalWrite(4, HIGH);

digitalWrite(5, LOW);

}

break;

}

}

 

RC Controller Code

 

// NRF24L01 UNO

// CE 7

// CSN 8

// SCK 13

// MOSI 11

// MISO 12


#include <SPI.h>

#include <nRF24L01.h>

#include <RF24.h>



int x_key = A0;

int y_key = A1;

int joystick[2];


RF24 radio(7, 8); // CE, CSN

const byte address[6] = "01010";


void setup() {

radio.begin();

radio.openWritingPipe(address);

radio.setPALevel(RF24_PA_MAX);

radio.stopListening();

Serial.begin(115200);

pinMode (x_key, INPUT);

pinMode (y_key, INPUT);


}


void loop() {


joystick[0] = analogRead(x_key);

joystick[1] = analogRead(y_key);


radio.write( joystick, sizeof(joystick));

Serial.println(joystick[1]);

Serial.println(joystick[0]);

}

 

You have just created your RC Car and it is that simple. To view my video on this RC car making, feel free to check out the video below :


Thank You and Good Luck Trying :)

Comments


bottom of page