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

Arduino Nano Controlled NRF24L01 Wireless Command Transmitter

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled NRF24L01 Wireless Command Transmitter

Circuit Documentation

Summary

This circuit is designed to interface an Arduino Nano with an NRF24L01 wireless transceiver module and a series of tactile switch buttons. The Arduino Nano serves as the central processing unit, reading inputs from the buttons and sending commands wirelessly via the NRF24L01 module. The buttons are used to send specific commands that the Arduino Nano translates into wireless signals. The circuit is powered by a 4 x AAA battery mount, providing the necessary voltage to the Arduino Nano and the NRF24L01 module.

Component List

Arduino Nano

NRF24L01

Tactile Switch Buttons - 12mm Square

4 x AAA Battery Mount

Wiring Details

Arduino Nano

NRF24L01

Tactile Switch Buttons - 12mm Square

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 run on the Arduino Nano. It initializes the NRF24L01 module and sets up the tactile buttons as inputs with internal pull-up resistors. When a button is pressed, the corresponding command is sent wirelessly to the receiver. The sendCommand function handles the transmission of commands to the NRF24L01 module.