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

Arduino UNO and NRF24L01 Wireless Joystick-Controlled Robot

View and Edit Project In Cirkit DesignerImage of Arduino UNO and NRF24L01 Wireless Joystick-Controlled Robot

Circuit Documentation

Summary

This circuit consists of two Arduino UNO microcontrollers, two NRF24L01 wireless transceivers, two KY-023 Dual Axis Joystick Modules, an L298N DC motor driver, and two motor and wheel assemblies. The circuit is designed to read joystick inputs and wirelessly transmit the data to control the motors.

Component List

  1. KY-023 Dual Axis Joystick Module

    • Pins: GND, +5V, VRx, VRy, SW
    • Description: A joystick module that provides analog output for X and Y axes and a digital output for the switch.
  2. NRF24L01

    • Pins: IRQ (not used), MOSI, CSN, VCC (3V), GND, CE, SCK, MISO
    • Description: A wireless transceiver module used for communication between the two Arduino UNOs.
  3. Arduino UNO

    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
    • Description: A microcontroller board based on the ATmega328P.
  4. L298N DC Motor Driver

    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
    • Description: A dual H-bridge motor driver module that allows control of the speed and direction of two DC motors.
  5. Motor and Wheels

    • Pins: vcc, GND
    • Description: A motor and wheel assembly used for movement.
  6. 7.4V Battery

    • Pins: +, -
    • Description: A power source for the motor driver.

Wiring Details

KY-023 Dual Axis Joystick Module (Joystick 1)

KY-023 Dual Axis Joystick Module (Joystick 2)

NRF24L01 (Transceiver 1)

NRF24L01 (Transceiver 2)

L298N DC Motor Driver

Motor and Wheels (Motor 1)

Motor and Wheels (Motor 2)

7.4V Battery

Documented Code

Arduino UNO (Transmitter)

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

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

void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_LOW);
  radio.stopListening();
}

void loop() {
  int joystick1_x = analogRead(A0);  // Read joystick 1 X-axis
  int joystick1_y = analogRead(A1);  // Read joystick 1 Y-axis
  int joystick2_x = analogRead(A2);  // Read joystick 2 X-axis
  int joystick2_y = analogRead(A3);  // Read joystick 2 Y-axis

  int data[] = {joystick1_x, joystick1_y, joystick2_x, joystick2_y};
  radio.write(&data, sizeof(data));  // Transmit joystick data
  delay(50);
}

Arduino UNO (Receiver)

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

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

int motor1_pwm = 3;  // Motor 1 PWM pin
int motor1_dir = 4;  // Motor 1 Direction pin
int motor2_pwm = 5;  // Motor 2 PWM pin
int motor2_dir = 6;  // Motor 2 Direction pin

void setup() {
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_LOW);
  radio.startListening();

  pinMode(motor1_pwm, OUTPUT);
  pinMode(motor1_dir, OUTPUT);
  pinMode(motor2_pwm, OUTPUT);
  pinMode(motor2_dir, OUTPUT);
}

void loop() {
  if (radio.available()) {
    int data[4];
    radio.read(&data, sizeof(data));  // Receive joystick data

    int joystick1_x = data[0];
    int joystick1_y = data[1];
    int joystick2_x = data[2];
    int joystick2_y = data[3];

    // Map joystick values to motor control
    int motor1_speed = map(joystick1_y, 0, 1023, -255, 255);
    int motor2_speed = map(joystick2_y, 0, 1023, -255, 255);

    // Control motor 1
    analogWrite(motor1_pwm, abs(motor1_speed));
    digitalWrite(motor1_dir, motor1_speed > 0);

    // Control motor 2
    analogWrite(motor2_pwm, abs(motor2_speed));
    digitalWrite(motor2_dir, motor2_speed > 0);
  }
}