in ,

Arduino, PCA9685 Servo Motor Driver 16 Chanel Module Tutorial

As a hobbyist and and electronic enthusiast, you might have heard of Servo Motors and their application. Servo Motors are used in robotics as well as automation projects in home and offices. They are used in door locks, aeroplane wings, robotic hands and they have countless other applications. Using Servo Motors you will have precise control over the movement. The PCA9685 is a 16 Channel 12 Bit PWM I2C-bus controlled Servo motor Driver. The Driver can very easily connected to your arduino, Raspberry Pie and easily programmed to control single or multiple servo motors and make your own RC plane, car, ship, quadrapod, hexapod or anything you want.
Image result for utsource logo

Sponsor Link

This Project is Sponsored by UTSource. UTSource is a professional electronic components supplier.
Easily Control Multiple Servo Motors using PCA9685 Servo Motor Driver Module and an Arduino
Watch this Video to Set this up.

Components Required 

What is a Servo Motor?Related image

So what is a Servo Motor? Servo Motor is a motor which is designed for specific precise angular protection.  they have gears and have an internal circuit which will provide feedback and helps in precisely adjusting the movement of the shaft. There are different variants of Servo Motors available in the market.  depending upon the type of voltage applied, there are AC and DC Servo Motors. Depending upon the type of gears – Metal Geared and non-metal geared for plastic geared Servo Motors. Depending upon the range of motion, there are 180 degree and 360 degree Servo Motors. And there are analog and digital servo motors.

How Do We Control Servo Motors?

In the case of a DC motor it will be having two terminals.  in one terminal we will apply a positive potential and in the other we will provide a negative potential.  once the circuit is complete the DC motor will start to rotate. when we reverse the terminal the DC motor will start to rotate in the opposite direction.

Image result for servo motor

Now let’s take a closer look at the Servo Motor. If you look carefully, you will see three wires coming out from the back of the servo motor. Usually it will be orange, red and brown; but it varies from motor to motor. One is for providing a positive voltage (+5 V, usually the red one)  and black one is for 0 V. But that is not enough we have to tell the motor in which angle it should rotate. For that we will use the third pin – the orange one. This is done by providing PWM signals through the signal Pin. What is Pulse Width Modulation? This is a way of getting analogue output using digital means.  I will make it a little bit clear. in digital world there are only two states – 0 and 1  or on and off  or 5 volt or 0 volt. Usually, using digital methods the only waveform or signal we can create is a square wave of varying On time and Off.  But this can be used to simulate and analogue waveform by adjusting the time the wave stays On and the time It stays Off. One way to do that is to make use of servo library which is available online. This library can be used to create PWM signals by writing analog values to one of the PWM pins. All you have to do is enter the value of the angle of rotation of the servo motor (between 0 and 180) and the library will take care of the rest of the hard work. But the problem here is there is a limit to the number of PWM pins available in the Arduino board. If you want to control more than that, you will have to use another Arduino Board. So how can we overcome this issue? Behold PCA9685 16 Channel Servo Motor Driver. PCA9685 16 Channel 12 Bit PWM I2C-bus controlled Servo motor Driver
 Image result for PCA9685 servo motor

Get Yours Now

The PCA9685 is a 16 Channel 12 Bit PWM I2C bus controlled Servo motor Driver. The Driver can very easily be connected to your Arduino, Raspberry Pi and easily programmed to control single or multiple servo motors and make your own RC plane, car, ship, quadrapod, hexapod or anything you want. Here the Arduino and PCA9685 16 Channel Servo Motor Driver communicate with each other using I2C protocol and the PCA9685 Servo Motor Driver will send PWM signals to the servo motor. Thus you can control multiple servo motors the way you want using a few lines of code. You can buy it from BangGood for a cheap price. Click Here to buy.

Get Started

Here, I used an easy to use voltage regulator circuit for hobbyist. This can be used in arduino, Raspberry Pi projects. Easy and Efficient Voltage Adjustment. The video will show you how to setup your own voltage regulator.
After setting up the regulator, Follow the below diagram and connect the Arduino board and PCA9685 16 Channel Servo Motor Driver.


Image result for PCA9685 arduino
There are two pins on the driver board for power; VCC and V+. It is important that, for the working of the IC inside the motor driver, 5V power supply is required. This 5 V can be provided from arduino’s 5 V pin as I did in the video.
Arduino’s 5 V should be connected to VCC only and not V+. V+ is used to power the motor. It will take more current than VCC.
 The SDA and SCL will be different for different arduino board. Just do a quick google search for the correct pins. I have mentioned some below.
Uno, Ethernet —–A4 (SDA), A5 (SCL) Mega256020 —– (SDA), 21 (SCL) Leonardo —– 2 (SDA), 3 (SCL) Due —– 20 (SDA), 21 (SCL), SDA1, SCL1
Do all the connections and make sure you double check it. Download and install adafruit library from here and launch arduino IDE.


Below is a simple code for controlling a single Servo.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

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

uint8_t servonum = 0;

void setup() 
Serial.println("16 channel Servo test!");
int pulseWidth(int angle)
int pulse_wide, analog_value;
pulse_wide = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
return analog_value;

void loop() {
pwm.setPWM(0, 0, pulseWidth(0));
pwm.setPWM(0, 0, pulseWidth(120));
pwm.setPWM(0, 0, pulseWidth(90));

Once the code is uploaded, if all the connections are correct, it should start the motor. Now its time for you to start the game. Let me know you views on the comment.
Rate the Project Did you find this page useful? Help us to improve by rating this page.
Arduino, PCA9685 Servo Motor Driver 16 Chanel Module Tutorial
4.4 rating based on 12,345 ratings
Overall rating: 4.4 out of 5 based on 253 reviews.

Written by Jithin


Leave a Reply
  1. Can we have a generic tutorial not using adafruits code as that does not compile under all Arduino platforms? they built it to support hardware they make so will not compile under digispark attiny85 and pro

  2. Did some further hacking and turns out that it is possible to mould the library for digispark Arduino platform.
    Add to the Adafruit_PWMServoDriver.h header file:

    #define TwoWire USI_TWI

    And since the USI chip does not clock the I2C in hardware it does not have a need for
    so does not include the method in its Wire.cpp and Wire.h
    One can either conditionally comment out the above statement in the examples OR add dummy method to the digistump Wire.cpp and Wire.h

    void USI_TWI::setClock(uint32_t clock) { // digispark Attiny boards do not have this feature!
    // twi_setFrequency(clock);

    Obviously it is likely some syntax may get trashed by comment filtering rules but hopefully enough information will survive to be usable without too much thought.

Leave a Reply

Your email address will not be published. Required fields are marked *

MMA7361 Gesture Controlled Robot

MMA7361 Accelerometer Arduino Tutorial


micro:bit – Compact and Cheap Microcontroller for your Project | microbit Tutorial