Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Controlled Robotic Vehicle with NRF24L01 Wireless Communication

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled Robotic Vehicle with NRF24L01 Wireless Communication

Circuit Documentation

Summary

This circuit is designed to wirelessly control a DC motor and a servo motor using two Arduino Nano microcontrollers and NRF24L01 transceiver modules. One Arduino Nano acts as a transmitter, reading input from an analog joystick and sending the data to the receiver. The other Arduino Nano acts as a receiver, controlling the DC motor through an L298N motor driver and a servo motor based on the received joystick data. The circuit is powered by a 12V battery, with a step-down module to provide the appropriate voltage levels to the components.

Component List

Microcontrollers

Communication Modules

Motors

Motor Driver

Power Supply

Input Devices

Wiring Details

Arduino Nano (Transmitter)

Arduino Nano (Receiver)

NRF24L01

DC Motor

Servo

L298N DC Motor Driver

LM2596 Step Down Module

Analog Joystick (Wokwi Compatible)

Documented Code

Transmitter Code (Arduino Nano)

//transmitter
// Library: TMRh20/RF24 (https://github.com/tmrh20/RF24/)
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>

RF24 radio(9, 8); // CE, CSN
const byte address[10] = "ADDRESS01";

int joyX = A0; // Joystick X-axis connected to analog pin A0
int joyY = A1; // Joystick Y-axis connected to analog pin A1

struct DataPackage {
  int x;
  int y;
};
DataPackage data;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  pinMode(joyX, INPUT);
  pinMode(joyY, INPUT);
}

void loop() {
  data.x = analogRead(joyX);  // Read X-axis value
  data.y = analogRead(joyY);  // Read Y-axis value
  radio.write(&data, sizeof(data));

  // Print joystick data for debugging
  Serial.print("X: ");
  Serial.print(data.x);
  Serial.print(" | Y: ");
  Serial.println(data.y);

  delay(100); // Adjust delay as needed
}

Receiver Code (Arduino Nano)

// Libraries for RF24 and Servo control
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
#include <Servo.h>

RF24 radio(9, 8); // CE, CSN
const byte address[10] = "ADDRESS01";

const int motorPin1 = 3;   // Pin to control first DC motor (PWM-capable)
const int motorPin2 = 10;   // Pin to control second DC motor (PWM-capable)
const int motorDirPin1 = 4; // Direction control pin for first motor
const int motorDirPin2 = 7; // Direction control pin for second motor
const int servoPin = 6;    // Pin to control servo

Servo myServo;          // Servo motor object
int motorSpeed1 = 0;    // Speed of the first DC motor
int motorSpeed2 = 0;    // Speed of the second DC motor

struct DataPackage {
  int x;
  int y;
};
DataPackage data;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();

  myServo.attach(servoPin); // Attach servo to the specified pin
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorDirPin1, OUTPUT);
  pinMode(motorDirPin2, OUTPUT);
}

void loop() {
  if (radio.available()) {
    radio.read(&data, sizeof(data));

    // Map joystick Y-axis to motor speeds
    motorSpeed1 = map(data.y, 0, 1023, -255, 255);
    motorSpeed2 = map(data.y, 0, 1023, -255, 255);
    
    int motorDirection1 = (motorSpeed1 >= 0) ? HIGH : LOW;
    int motorDirection2 = (motorSpeed2 >= 0) ? HIGH : LOW;
    
    digitalWrite(motor