Arduino R3 Basic Servo With the PCA9685

Print Friendly, PDF & Email

Arduino R3 Basic Servo With the PCA9685

In this project were going to see how to connect multiple servos to the PCA9685 breakout board

ref :

Wiring Diagram

  1. 1 x Arduino
  2. 1 x PCA9685 breakout board
  3. 1 x Servo
  4. 1 x Variable Resistor or Joystick ( Several Variable resistors)
Wire Diagram Part 1
PCA9685 Wire Diagram Part 2


When plugging in the Servo motor connections, the number starts at 0 to 15 from left to right.

Using Servo Motors with the Arduino | DroneBot Workshop
PCA9685 Pin Diagram

Arduino Sketch

The Adafruit PWM Servo Driver library has to be added to the Arduino IDE through the Sketch -> Include Library -> Manage Library’s top toolbar menu.

#include <Wire.h>

#include <Adafruit_PWMServoDriver.h>

#define MIN_PULSE_WIDTH 650
#define MAX_PULSE_WIDTH 2350
#define FREQUENCY 50

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

int controlA = A0;

int motorA = 0;

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


void moveMotor(int controlIn, int motorOut)
  int pulse_wide, pulse_width, potVal;

  potVal = analogRead(controlIn);

  pulse_wide = map(potVal, 0,1023, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
  pulse_width = int(float(pulse_wide)/1000000 * FREQUENCY * 4096);

  pwm.setPWM(motorOut , 0, pulse_width);

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

  moveMotor(controlA, motorA);