Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Wireless Servo Control with NRF24L01 and LED Indicators

Image of Arduino UNO Based Wireless Servo Control with NRF24L01 and LED Indicators

Circuit Documentation

Summary

The circuit consists of two Arduino UNO microcontrollers, each interfaced with an NRF24L01 radio module. Additionally, the circuit includes two push switches, four red LEDs, and two servos. The purpose of the circuit is to demonstrate wireless communication between the two Arduinos using the NRF24L01 modules, where one Arduino acts as a transmitter and the other as a receiver. The transmitter Arduino sends signals upon button presses, which are received by the receiver Arduino to control servos and LEDs.

Component List

Microcontrollers

  • Arduino UNO: A microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

Radio Modules

  • NRF24L01: A 2.4GHz ISM band transceiver. Includes features such as 125 channels, multi-point communication, and frequency hopping.

Switches

  • 2Pin Push Switch: A simple push-to-make switch that closes the circuit when pressed.

LEDs

  • LED: Two Pin (red): A basic red LED with an anode and cathode for indicating status or events.

Servos

  • Servo: A rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity, and acceleration.

Wiring Details

Arduino UNO (Receiver)

  • 3.3V to NRF24L01 VCC
  • GND to NRF24L01 GND, Push Switches, and LEDs
  • Digital Pins:
    • D13 to NRF24L01 SCK
    • D12 to NRF24L01 MISO
    • D11 to NRF24L01 MOSI
    • D10 to NRF24L01 CSN
    • D9 to NRF24L01 CE
    • D5 to Servo1 pulse
    • D6 to LED1 anode
    • D7 to LED2 anode

Arduino UNO (Transmitter)

  • 3.3V to NRF24L01 VCC
  • 5V to Servos VCC
  • GND to NRF24L01 GND, Servos GND, and LEDs
  • Digital Pins:
    • D13 to NRF24L01 SCK
    • D12 to NRF24L01 MISO
    • D11 to NRF24L01 MOSI
    • D10 to NRF24L01 CSN
    • D9 to NRF24L01 CE
    • D2 to Push Switch B1 Input +
    • D3 to Push Switch B2 Input +
    • D4 to LED L1 anode
    • D5 to LED L2 anode
    • D6 to Servo2 pulse

NRF24L01

  • VCC to Arduino 3.3V
  • GND to Arduino GND
  • CE to Arduino D9
  • CSN to Arduino D10
  • SCK to Arduino D13
  • MOSI to Arduino D11
  • MISO to Arduino D12

2Pin Push Switch

  • Input + to Arduino D2/D3
  • Output + to Arduino GND

LED: Two Pin (red)

  • Anode to Arduino D4/D5/D6/D7
  • Cathode to Arduino GND

Servo

  • VCC to Arduino 5V
  • GND to Arduino GND
  • Pulse to Arduino D5/D6

Documented Code

Receiver Arduino Code

/*RF24 radio module:

CE: Pin 9
CSN: Pin 10
Servos:

Servo1: Pin 3
Servo2: Pin 5
LEDs:

LED1: Pin 6
LED2: Pin 7
 * This Arduino Sketch receives signals from an NRF24L01 module.
 * If the received signal is 'A', it turns Servo1 from 0 to 90 degrees and back to 0.
 * If the received signal is 'B', it turns Servo2 from 0 to 90 degrees and back to 0.
 * Additionally, if the received signal is 'A', it turns on LED1.
 * If the received signal is 'B', it turns on LED2.
 */

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

RF24 radio(9, 10); // CE, CSN pins
const byte address[6] = "00001";
Servo servo1;
Servo servo2;
const int led1Pin = 6; // LED1 connected to pin 6
const int led2Pin = 7; // LED2 connected to pin 7

void setup() {
  servo1.attach(3); // Attach Servo1 to pin 3
  servo2.attach(5); // Attach Servo2 to pin 5
  pinMode(led1Pin, OUTPUT); // Set LED1 pin as output
  pinMode(led2Pin, OUTPUT); // Set LED2 pin as output
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    if (text[0] == 'A') {
      servo1.write(90);
      digitalWrite(led1Pin, HIGH); // Turn on LED1
      delay(1000);
      servo1.write(0);
      digitalWrite(led1Pin, LOW); // Turn off LED1
    } else if (text[0] == 'B') {
      servo2.write(90);
      digitalWrite(led2Pin, HIGH); // Turn on LED2
      delay(1000);
      servo2.write(0);
      digitalWrite(led2Pin, LOW); // Turn off LED2
    }
  }
}

Transmitter Arduino Code

/*
 * This Arduino Sketch transmits signals using an NRF24L01 module.
 * If button B1 is pressed, it sends the signal 'A' and turns on LED L1.
 * If button B2 is pressed, it sends the signal 'B' and turns on LED L2.
 */

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

RF24 radio(9, 10); // CE, CSN pins
const byte address[6] = "00001";
const int button1Pin = 2; // B1 connected to pin 2
const int button2Pin = 3; // B2 connected to pin 3
const int led1Pin = 4; // L1 connected to pin 4
const int led2Pin = 5; // L2 connected to pin 5

void setup() {
  pinMode(button1Pin, INPUT_PULLUP); // Set B1 pin as input with pull-up
  pinMode(button2Pin, INPUT_PULLUP); // Set B2 pin as input with pull-up
  pinMode(led1Pin, OUTPUT); // Set L1 pin as output
  pinMode(led2Pin, OUTPUT); // Set L2 pin as output
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  if (digitalRead(button1Pin) == LOW) {
    const char text[] = "A";
    radio.write(&text, sizeof(text));
    digitalWrite(led1Pin, HIGH); // Turn on L1
    delay(500); // Debounce delay
    digitalWrite(led1Pin, LOW); // Turn off L1
  }
  if (digitalRead(button2Pin) == LOW) {
    const char text[] = "B";
    radio.write(&text, sizeof(text));
    digitalWrite(led2Pin, HIGH); // Turn on L2
    delay(500); // Debounce delay
    digitalWrite(led2Pin, LOW); // Turn off L2
  }
}