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

Arduino-Controlled Robotics Platform with NRF24L01 Wireless Communication

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Robotics Platform with NRF24L01 Wireless Communication

Circuit Documentation

Summary

This circuit is designed to control a robotic vehicle with wireless communication capabilities. It includes two Arduino Nano microcontrollers, one acting as a transmitter with joystick inputs and a pushbutton, and the other as a receiver controlling motor drivers and a sprayer system. The NRF24L01 modules enable wireless communication between the Arduinos. The circuit also features motor drivers for vehicle movement, ultrasonic sensors for distance measurement, MOSFETs for pump control, and a power supply system with a rocker switch.

Component List

Microcontrollers

Communication Modules

Motor Drivers

Sensors

Actuators

Power Supply

Control Inputs

Power Control

Wiring Details

Arduino Nano (Transmitter)

Arduino Nano (Receiver)

NRF24L01

L298N DC Motor Driver

HC-SR04 Ultrasonic Sensor

Mosfet

Power Supply

Documented Code

Arduino Nano (Transmitter) Code

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

// Pin assignments for joysticks, button, and NRF24L01
#define JOYSTICK1_X A0
#define JOYSTICK1_Y A1
#define JOYSTICK2_X A2
#define JOYSTICK2_Y A3
#define BUTTON_PIN 4

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

// Data structure to send data for motion, sprayer control, and button state
struct DataPackage {
  int joystick1_x;
  int joystick1_y;
  int joystick2_x;
  int joystick2_y;
  bool button;
};

DataPackage data;

void setup() {
  // Initialize joysticks and button
  pinMode(JOYSTICK1_X, INPUT);
  pinMode(JOYSTICK1_Y, INPUT);
  pinMode(JOYSTICK2_X, INPUT);
  pinMode(JOYSTICK2_Y, INPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  // Initialize NRF24L01
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  // Read values from the first joystick for motion control
  data.joystick1_x = analogRead(JOYSTICK1_X);
  data.joystick1_y = analogRead(JOYSTICK1_Y);

  // Read values from the second joystick for sprayer control
  data.joystick2_x = analogRead(JOYSTICK2_X);
  data.joystick2_y = analogRead(JOYSTICK2_Y);

  // Read the button state (pressed or not)
  data.button = !digitalRead(BUTTON_PIN); // Button is active low

  // Send the data package via NRF24L01
  radio.write(&data, sizeof(DataPackage));

  // Small delay to avoid overwhelming the receiver
  delay(50);
}

Arduino Nano (Receiver) Code

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

RF24 radio(9, 10); // CE, CSN

const byte address[6] = "00001";

struct DataPacket {
  int joy1X;
  int joy1Y;
  int joy2X;
  int joy2Y;
  bool buttonState;
};

DataPacket data;

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

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

    // Send data to the second Arduino via Serial
    Serial.write((uint8_t*)&data, sizeof(DataPacket));
  }

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