16 channel servo motor control driver board for Arduino

16 channel servo motor control driver board for Arduino

Hello, welcome back. In this tutorial, we will learn how to control a lot of servo motors using one Arduino board. Also, we use a 16 channel PWM servo motor driver board for this. We can control easily 16 servo motors through this driver using two Arduino pins. Also, if you want to control a lot of servo motors, you can use several of these driver boards. This tutorial explains step by step how to control four servo motors. Also, you can easily do projects like robot arms and hexapod walkers by using the knowledge in this tutorial.

16 channel PWM servo motor driver

16 channel servo motor control driver board for Arduino

This driver board mainly includes PCA9685 PWM driver IC. Also, we can connect this driver board to the Arduino board using the I2C communication. That is, we can control 16 servo motors using the SCL and SDA pins on the Arduino board. If you want to control more than that, you can continue to connect the driver board as a chain. In this way, 62 driver boards can be connected to one I2C bus. In particular, this driver board must be provided with an external 5v potential for activation. Do not connect other devices as the current available from a PWM pin is like 10mA.

PIN structure of this PWM driver board

16 channel servo motor control driver board for Arduino

OK, let’s learn how to connect this driver board to the Arduino step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, connect these components. To do this, use the circuit diagram below.

16 channel servo motor control driver board for Arduino

Step 3

Thirdly, let’s creates the program. It is as follows.

PWM driver library — Download

Example 1

/*servo motor driver board control
   https://srituhobby.com
*/

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

Adafruit_PWMServoDriver srituhobby = Adafruit_PWMServoDriver();

#define servoMIN 150
#define servoMAX 600

void setup() {
  Serial.begin(9600);
  srituhobby.begin();
  srituhobby.setPWMFreq(60);
}

void loop() {
  for (int servo = 0; servo < 4; servo++ ) {
    srituhobby.setPWM(servo, 0, servoMIN);
    Serial.println(servo);
    delay(300);
  }

  for (int servo = 3; servo >= 0; servo-- ) {
    srituhobby.setPWM(servo, 0, servoMAX);
    Serial.println(servo);
    delay(300);
  }
}
Code explanation

Firstly, library files are included. After, the object was created for this library.

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

Adafruit_PWMServoDriver srituhobby = Adafruit_PWMServoDriver();

Secondly, the starting and ending values of servo motors are defined.

#define servoMIN 150
#define servoMAX 600

In the setup function, the serial monitor and driver library begins.

void setup() {
  Serial.begin(9600);
  srituhobby.begin();
  srituhobby.setPWMFreq(60);
}

In the loop function, the servo motor turns left and right one by one. For that, two for loop functions are used.

void loop() {
  for (int servo = 0; servo < 4; servo++ ) {
    srituhobby.setPWM(servo, 0, servoMIN);
    Serial.println(servo);
    delay(300);
  }

  for (int servo = 3; servo >= 0; servo-- ) {
    srituhobby.setPWM(servo, 0, servoMAX);
    Serial.println(servo);
    delay(300);
  }
}

Step 4

Lastly, select board and port. Afterward, upload this code to the Arduino board.

Example 2

/*servo motor driver board control
 * https://srituhobby.com
 */
 
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver srituhobby = Adafruit_PWMServoDriver();

#define servoMIN 150
#define servoMAX 600

byte servo = 0;

void setup() {
  Serial.begin(9600);
  srituhobby.begin();
  srituhobby.setPWMFreq(60);
}

void loop() {

  for (int pulse = servoMIN; pulse < servoMAX; pulse++) {
    srituhobby.setPWM(servo, 0, pulse);
    Serial.println(servo);
  }
  delay(100);

  for (int pulse = servoMAX; pulse > servoMIN; pulse--) {
    srituhobby.setPWM(servo, 0, pulse);
    Serial.println(servo);
  }
  delay(100);

  servo++;
  if (servo > 3) {
    servo = 0;
  }
}

Okay, upload these two codes separately and enjoy it. The full video guide is given below. So, we will meet in the next tutorial.

Similar Posts

Leave a Reply

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