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

Arduino Nano Controlled Robotic Vehicle with Wireless Joystick and Servo Steering

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled Robotic Vehicle with Wireless Joystick and Servo Steering

Circuit Documentation

Summary

This circuit is designed to remotely control a DC motor and a servo motor using two Arduino Nano microcontrollers and NRF24L01 wireless transceiver modules. The circuit includes a joystick for user input, a DC motor driver to manage the motor's direction and speed, and a step-down module to regulate the power supply. The first Arduino Nano acts as a transmitter, reading the joystick's position and sending the data wirelessly. The second Arduino Nano receives the data and controls the DC motor and servo motor accordingly.

Component List

Microcontrollers

Communication Modules

Motors

Motor Driver

Power Supply

Input Devices

Wiring Details

Arduino Nano (Transmitter)

Arduino Nano (Receiver)

L298N DC Motor Driver

NRF24L01 (Transmitter and Receiver)

Servo

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(motorDirPin1, motorDirection1);
    digitalWrite(motorDirPin2, motorDirection2);

    analogWrite(motorPin1, abs(motorSpeed1));
    analogWrite(motorPin