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

Arduino-Based Wireless Motor and Water Pump Controller with nRF24L01 and Joystick

View and Edit Project In Cirkit DesignerImage of Arduino-Based Wireless Motor and Water Pump Controller with nRF24L01 and Joystick

Circuit Documentation

Summary

This circuit involves an Arduino UNO and an Arduino Mega 2560, each interfacing with various components to control motors, a water pump, and communicate wirelessly using nRF24L01 modules. The Arduino UNO reads joystick inputs and sends data wirelessly to the Arduino Mega 2560, which controls the motors and a water pump via a relay.

Component List

  1. nRF24L01

    • Description: Wireless transceiver module
    • Pins: GND, VCC, CE, CSN, SCK, MOSI, MISO, IRQ
  2. L298 Dual H Bridge Motor Speed Controller

    • Description: Motor driver for controlling two motors
    • Pins: 5V, ENA, IN1, IN2, GND, IN4, IN3, 12V, Motor 1 Power, Motor 1 GND, Motor 2 Power, Motor 2 GND
  3. Joystick Module

    • Description: Joystick for user input
    • Pins: SW, VRY, VRX, VCC, GND
  4. 1-Channel Relay (5V 10A)

    • Description: Relay module for switching high-power devices
    • Pins: NC, signal, C, power, NO, ground
  5. Water Pump

    • Description: Pump for moving water
    • Pins: positive, negative
  6. Arduino UNO

    • Description: Microcontroller board
    • 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
  7. Arduino Mega 2560

    • Description: Microcontroller board with more I/O pins
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, D21/SCL, D20/SDA, D19/RX1, D18/TX1, D17 PWM/RX2, D16 PWM/TX2, D15/RX3, D14/TX3, D0 RX0, D1 TX0, D2 PWM, D3 PWM, D4 PWM, D5 PWM, D6 PWM, D7 PWM, D8 PWM, D9 PWM, D10 PWM, D11 PWM, D12 PWM, D13 PWM, AREF, SDA, SCL, D52, D50, D48, D46, D44, D42, D40, D38, D36, D34, D32, D30, D28, D26, D24, D22, D53, D51, D49, D47, D45, D43, D41, D39, D37, D35, D33, D31, D29, D27, D25, D23, 6swdw
  8. Battery 12V

    • Description: Power source
    • Pins: +, -
  9. MRB Planetary Gearbox Motor

    • Description: Motor with planetary gearbox
    • Pins: +, -

Wiring Details

nRF24L01 (Connected to Arduino UNO)

L298 Dual H Bridge Motor Speed Controller (Connected to Arduino Mega 2560)

Joystick Module (Connected to Arduino UNO)

1-Channel Relay (Connected to Arduino Mega 2560)

Water Pump

nRF24L01 (Connected to Arduino Mega 2560)

Code Documentation

Arduino UNO Code

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

// Pin untuk Joystick
const int joystickXPin = A0; // X-axis
const int joystickYPin = A1; // Y-axis

// Pin untuk Button Relay
const int buttonPin = 2; // Sambungkan push button ke Pin 2

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

void setup() {
  // Tetapkan pin untuk button
  pinMode(buttonPin, INPUT_PULLUP); // Button dengan pull-up resistor

  // Mulakan Serial dan nRF24L01
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_HIGH); // Tetapkan kuasa tinggi untuk kestabilan
  radio.stopListening();
}

void loop() {
  // Baca nilai joystick
  int joyX = analogRead(joystickXPin);
  int joyY = analogRead(joystickYPin);

  // Baca status button
  bool buttonState = digitalRead(buttonPin) == LOW; // LOW jika button ditekan

  // Data yang akan dihantar
  int data[3] = {joyX, joyY, buttonState}; // Tambah status button sebagai elemen ketiga

  // Hantar data ke penerima
  bool success = radio.write(&data, sizeof(data));

  // Paparkan status penghantaran di Serial Monitor
  if (success) {
    Serial.print("Data dihantar: ");
    Serial.print("X: ");
    Serial.print(joyX);
    Serial.print(" Y: ");
    Serial.print(joyY);
    Serial.print(" Relay: ");
    Serial.println(buttonState ? "ON" : "OFF");
  } else {
    Serial.println("Penghantaran data gagal");
  }

  delay(100); // Kurangkan frekuensi penghantaran untuk kestabilan
}

Arduino Mega 2560 Code

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and the code used for the microcontrollers.