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

Arduino Nano Controlled Servo and LED System with NRF24L01 Wireless Communication

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled Servo and LED System with NRF24L01 Wireless Communication

Circuit Documentation

Summary

This circuit is designed to receive signals from a transmitter to control LEDs and a servo motor. It includes two Arduino Nano microcontrollers, NRF24L01 wireless modules for communication, a servomotor, analog joysticks, tactile switch buttons, a pushbutton, LEDs, resistors, a transistor, batteries, and rocker switches. The primary Arduino Nano is configured to control a servomotor and toggle the state of an LED based on the received RF signals. It also allows for manual adjustment of the servo position using two tactile switch buttons. The secondary Arduino Nano's code is not provided, suggesting it may be used for future expansion or currently serves a simple or placeholder function.

Component List

Microcontrollers

Communication Modules

Input Devices

Output Devices

Power Supply

Passive Components

Prototyping Boards

Wiring Details

Arduino Nano

NRF24L01

Servomotor MG90S

Analog Joystick (Wokwi Compatible)

Tactile Switch Buttons - 12mm Square

Pushbutton

LED: Two Pin (green)

Resistor

NPN-Transistor

ProtoSnap - Pro Mini - Protoboard

5v battery

Rocker switch

Documented Code

Receiver Code for Arduino Nano (Instance ID: 08f9f7ca-670a-4772-8cdc-e666b82695dd)

/*
 * Receiver Code
 * This code receives signals from the transmitter to control LEDs and a servo.
 * The green button toggles LEDs, the right joystick controls the servo, and
 * two black buttons fine-tune the servo position.
 */

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

#define LED_PIN 7
#define SERVO_PIN 2
#define BUTTON_LEFT_PIN 5
#define BUTTON_RIGHT_PIN 6

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

int ledState = LOW;
int servoPos = 90;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_LEFT_PIN, INPUT_PULLUP);
  pinMode(BUTTON_RIGHT_PIN, INPUT_PULLUP);
  myServo.attach(SERVO_PIN);
  myServo.write(servoPos);
  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 (strcmp(text, "TOGGLE_LED") == 0) {
      ledState = !ledState;
      digitalWrite(LED_PIN, ledState);
    } else if (strncmp(text, "SERVO", 5) == 0) {
      int pos = atoi(&text[5]);
      servoPos = constrain(pos, 0, 180);
      myServo.write(servoPos);
    }
  }
  if (digitalRead(BUTTON_LEFT_PIN) == LOW) {
    servoPos = max(servoPos - 1, 0);
    myServo.write(servoPos);
    delay(100);
  }
  if (digitalRead(BUTTON_RIGHT_PIN) == LOW) {
    servoPos = min(servoPos + 1, 180);
    myServo.write(servoPos);
    delay(100);
  }
}

Placeholder Code for Arduino Nano (Instance ID: bc002bc0-4900-43b4-975e-eefde7c74370)

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

}

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

}

The second Arduino Nano does not have any specific functionality defined in the provided code. It may be used for future expansion or currently serves a simple or placeholder function.