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

Arduino UNO and Adafruit PCA9685 Controlled Multi-Servo Tester

View and Edit Project In Cirkit DesignerImage of Arduino UNO and Adafruit PCA9685 Controlled Multi-Servo Tester

Circuit Documentation

Summary

This circuit is designed to control multiple micro servos using an Arduino UNO and an Adafruit PCA9685 PWM Servo Breakout board. The servos are connected to the PWM outputs of the PCA9685, which is controlled by the Arduino via I2C communication. The Arduino runs a sketch to test the wiring and functionality of the servos by rotating them back and forth.

Component List

  1. Micro servo 9G

    • Description: A small and lightweight servo motor commonly used in RC models and small robotics.
    • Pins: GND, +5V, PWM
  2. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, and is programmable with the Arduino IDE.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  3. Adafruit PCA9685 PWM Servo Breakout

    • Description: A 16-channel PWM driver board that can control up to 16 servos or LEDs with I2C interface.
    • Pins: 5.0V, GND, PWRIN, PWM7, PWM6, PWM5, PWM4, PWM3, PWM2, PWM1, PWM0, VCC, SDA, SCL, OE, PWM15, PWM14, PWM13, PWM12, PWM11, PWM10, PWM9, PWM8

Wiring Details

Micro servo 9G (1)

Micro servo 9G (2)

Micro servo 9G (3)

Micro servo 9G (4)

Arduino UNO

Adafruit PCA9685 PWM Servo Breakout

Code Documentation

Arduino UNO Code

/*
 * This Arduino sketch is designed to test the wiring of multiple servos
 * connected to an Adafruit PCA9685 PWM Servo Breakout board. The servos
 * will rotate back and forth to ensure that all connections are working
 * correctly.
 */

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

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

void setup() {
  pwm.begin();
  pwm.setPWMFreq(60); // Analog servos run at ~60 Hz
}

void loop() {
  for (int pos = 0; pos <= 180; pos++) {
    setAllServos(pos);
    delay(15); // Wait for the servos to reach the position
  }
  for (int pos = 180; pos >= 0; pos--) {
    setAllServos(pos);
    delay(15); // Wait for the servos to reach the position
  }
}

void setAllServos(int pos) {
  int pulseLength = map(pos, 0, 180, 150, 600);
  pwm.setPWM(0, 0, pulseLength); // Servo 1
  pwm.setPWM(4, 0, pulseLength); // Servo 2
  pwm.setPWM(8, 0, pulseLength); // Servo 3
  pwm.setPWM(12, 0, pulseLength); // Servo 4
}

Adafruit PCA9685 PWM Servo Breakout Code

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

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

void setup() {
  pwm.begin();
  pwm.setPWMFreq(60); // Analog servos run at ~60 Hz
}

void loop() {
  for (int pos = 0; pos <= 180; pos++) {
    setServoPosition(0, pos);
    delay(15); // Wait for the servo to reach the position
  }
  for (int pos = 180; pos >= 0; pos--) {
    setServoPosition(0, pos);
    delay(15); // Wait for the servo to reach the position
  }
}

void setServoPosition(int servoNum, int pos) {
  int pulseLength = map(pos, 0, 180, 150, 600);
  pwm.setPWM(servoNum, 0, pulseLength);
}

This documentation provides a comprehensive overview of the circuit, including the components used, their wiring details, and the code running on the microcontrollers.