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

Arduino Nano and NRF24L01 Based Wireless Remote Control

View and Edit Project In Cirkit DesignerImage of Arduino Nano and NRF24L01 Based Wireless Remote Control

Circuit Documentation

Summary

This circuit is designed to interface an Arduino Nano with an NRF24L01 wireless transceiver module and multiple pushbuttons. The pushbuttons are used to send commands wirelessly via the NRF24L01 module. The Arduino Nano is programmed to read the state of the pushbuttons and send corresponding commands to control a remote device. The circuit is powered by a 4 x AAA battery mount, providing the necessary voltage for the Arduino Nano and the NRF24L01 module.

Component List

Pushbutton

NRF24L01

4 x AAA Battery Mount

Arduino Nano

Wiring Details

Pushbuttons

NRF24L01

4 x AAA Battery Mount

Documented Code

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

// Pin definitions for the tactile push buttons
const int button1Pin = 2;  // Forward
const int button2Pin = 3;  // Backward
const int button3Pin = 4;  // Left
const int button4Pin = 5;  // Right
const int button5Pin = 6;  // Return to Origin

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

// Commands
enum Commands {
  FORWARD,
  BACKWARD,
  LEFT,
  RIGHT,
  STOP,
  RETURN_TO_ORIGIN
};

void setup() {
  // Set up buttons as inputs
  pinMode(button1Pin, INPUT_PULLUP);
  pinMode(button2Pin, INPUT_PULLUP);
  pinMode(button3Pin, INPUT_PULLUP);
  pinMode(button4Pin, INPUT_PULLUP);
  pinMode(button5Pin, INPUT_PULLUP);

  // Start the NRF24L01 radio
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_LOW);
}

void loop() {
  // Check button states
  if (digitalRead(button1Pin) == LOW) {
    sendCommand(FORWARD);
    delay(200); // Debounce delay
  }
  if (digitalRead(button2Pin) == LOW) {
    sendCommand(BACKWARD);
    delay(200); // Debounce delay
  }
  if (digitalRead(button3Pin) == LOW) {
    sendCommand(LEFT);
    delay(200); // Debounce delay
  }
  if (digitalRead(button4Pin) == LOW) {
    sendCommand(RIGHT);
    delay(200); // Debounce delay
  }
  if (digitalRead(button5Pin) == LOW) {
    sendCommand(RETURN_TO_ORIGIN);
    delay(200); // Debounce delay
  }
}

// Function to send commands to the receiver
void sendCommand(Commands cmd) {
  radio.stopListening(); // Stop listening before sending
  radio.write(&cmd, sizeof(cmd)); // Send the command
  radio.startListening(); // Start listening again
}

This code is designed to be uploaded to the Arduino Nano. It initializes the pushbuttons and NRF24L01 module, then continuously checks the state of the pushbuttons. When a button is pressed, it sends a corresponding command wirelessly to the receiver. The sendCommand function is used to send the commands through the NRF24L01 module.