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

Arduino UNO and 16-Channel PWM Servo Driver Controlled Robotic Arm with Battery Power

View and Edit Project In Cirkit DesignerImage of Arduino UNO and 16-Channel PWM Servo Driver Controlled Robotic Arm with Battery Power

Circuit Documentation

Summary

This circuit is designed to control multiple servos using two 16-Channel PWM Servo Drivers and an Arduino UNO. The servos are powered by a 5V battery, and the Arduino UNO is used to send control signals to the PWM drivers, which in turn control the servos. The circuit includes four MG996R servos, each connected to one of the PWM channels on the servo drivers.

Component List

  1. 16-Channel PWM Servo Driver

    • Description: A driver board that can control up to 16 servos using PWM signals.
    • Pins: V+, VCC, SDA, SCL, OE, GND, Vin+, Vin-, PWM1 to PWM16
  2. MG996R Servo Motor

    • Description: A high-torque servo motor commonly used in robotics.
    • Pins: GND, VCC, SIG
  3. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P, used for various embedded applications.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0 to A5, SCL, SDA, AREF, D0 to D13
  4. 5V Battery

    • Description: A power source providing 5V DC.
    • Pins: positive, negative

Wiring Details

16-Channel PWM Servo Driver (1)

16-Channel PWM Servo Driver (2)

MG996R Servo Motor (1)

MG996R Servo Motor (2)

MG996R Servo Motor (3)

MG996R Servo Motor (4)

Arduino UNO

5V Battery

Code Documentation

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// Initialize PCA9685
Adafruit_PWMServoDriver pca9685 = Adafruit_PWMServoDriver();

// Servo limits (customize according to your servo type)
#define SERVOMIN 150 // Minimum pulse length (0 degrees)
#define SERVOMAX 600 // Maximum pulse length (180 degrees)

// Setup function
void setup() {
  Serial.begin(9600);
  Serial.println("Initializing PCA9685");

  pca9685.begin();
  pca9685.setPWMFreq(50); // Set PWM frequency to ~50Hz for servos
}

// Function to move servo to a position
void moveServo(int servoNum, int pos) {
  int pulse = map(pos, 0, 180, SERVOMIN, SERVOMAX); // Map angle to PWM value
  pca9685.setPWM(servoNum, 0, pulse);
}

// Loop to create simultaneous movement for 4 servos
void loop() {
  // Move 4 servos from 0 to 180 degrees
  for (int pos = 0; pos <= 180; pos += 10) {
    moveServo(0, pos); // Servo 0
    moveServo(1, 180 - pos); // Servo 1 (reverse direction)
    moveServo(2, pos); // Servo 2
    moveServo(3, 180 - pos); // Servo 3 (reverse direction)
    delay(100);
  }

  // Move 4 servos from 180 to 0 degrees
  for (int pos = 180; pos >= 0; pos -= 10) {
    moveServo(0, pos); // Servo 0
    moveServo(1, 180 - pos); // Servo 1 (reverse direction)
    moveServo(2, pos); // Servo 2
    moveServo(3, 180 - pos); // Servo 3 (reverse direction)
    delay(100);
  }
}

This code initializes the PCA9685 PWM driver and sets up a loop to move four servos simultaneously. The servos are moved from 0 to 180 degrees and then back from 180 to 0 degrees, creating a back-and-forth motion. The moveServo function maps the desired angle to the appropriate PWM pulse length and sends the signal to the specified servo.