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

Arduino UNO Controlled Multi-Servo System with NRF24L01 Wireless Communication

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Multi-Servo System with NRF24L01 Wireless Communication

Circuit Documentation

Summary of the Circuit

This circuit is designed to control multiple servo motors using an Arduino UNO as the main microcontroller, interfaced with an Adafruit PCA9685 PWM Servo Breakout board to drive the servos. Communication with external devices is facilitated by an NRF24L01 transceiver module. The circuit is powered by a 9V battery, and an electrolytic capacitor is used for voltage smoothing.

Component List

Arduino UNO

Servo Motors

NRF24L01

Adafruit PCA9685 PWM Servo Breakout

9V Battery

Electrolytic Capacitor

Wiring Details

Arduino UNO

Servo Motors

NRF24L01

Adafruit PCA9685 PWM Servo Breakout

9V Battery

Electrolytic Capacitor

Documented Code

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

// nRF24L01 Setup: CE and CSN pins
RF24 radio(9, 10);  // CE = Pin 9, CSN = Pin 10
const byte address[6] = "00001";  // Must match transmitter address

// Create PCA9685 PWM driver object
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

int potValues[6];  // Array to store the received potentiometer values

// Servo motor pulse range (150 - 600 is typical for many servos)
int servoMin = 150;
int servoMax = 600;

void setup()
{
  Serial.begin(9600);

  // Initialize the nRF24L01
  radio.begin();
  radio.openReadingPipe(0, address);  // Set the receiver address
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();  // Set as receiver

  // Initialize the PCA9685
  pwm.begin();
  pwm.setPWMFreq(50);  // Set PWM frequency to 50Hz (for servos)
}

void loop()
{
  // Check if data is available
  if (radio.available()) 
  {
    // Receive the potentiometer values
    radio.read(&potValues, sizeof(potValues));

    // Use the potentiometer values to control the servos
    for (int i = 0; i < 6; i++) 
    {
      int pulseWidth = map(potValues[i], 0, 1023, servoMin, servoMax);  // Map to servo pulse width
      pwm.setPWM(i, 0, pulseWidth);  // Set PWM for the ith servo
    }
  }
}

This code is responsible for initializing the NRF24L01 module and the PCA9685 PWM driver, receiving potentiometer values wirelessly, and controlling the servo motors by mapping the received values to the appropriate pulse widths.