PCA9685 16-Channel Servo Driver Module
When you encounter a situation where the PWM output pins of your microcontroller are insufficient for a project, the PCA9685 16-channel servo driver can quickly solve this issue. As long as your main controller chip supports I2C communication, it can communicate with the PCA9685 to simultaneously control multiple servos. The PCA9685 is an I2C-controlled 16-channel servo driver with an integrated PWM driver and a clock, meaning it is quite different from the TLC5940 series, as you do not need to continuously send signals and occupy your microcontroller. It is compatible with 5V systems, which means you can also safely control and drive up to 6V outputs with a 3.3V microcontroller (when controlling white or blue indicator lights, you can also use 3.3V or higher voltage). The address selection pins allow you to connect up to 62 driver boards on a single I2C bus, providing a total of 992 PWM outputs, which is a massive resource. The module supports an adjustable frequency of approximately 1.6kHz PWM output and provides 12-bit resolution for stepper motors. It offers configurable push-pull or open-drain outputs, and the output enable pin allows you to quickly disable all outputs.
Module Source
Purchase Link: https://detail.tmall.com/item.htm?_u=52t4uge5cc3d&id=624960039615&spm=a1z09.2.0.0.47582e8dqqFD4i
Baidu Netdisk Download Link: https://pan.baidu.com/s/1FjoAuJm387bxaZxS6g9HEg
Password:8888
Specifications
Operating Voltage:3.3V~5V
Rated Current: 15mA
Control Method: Serial
Dimensions: 21mm (Length)*21mm (Width)
Hardware Interface
- Connect the SDA and SCL pins of the PCA9685 module to the A4 (SDA) and A5 (SCL) pins of the development board, respectively.
- Provide appropriate power supply to the PCA9685 module, typically 5V, but ensure it is compatible with your servos.
- Connect the signal lines of the servos to the PWM output pins of the PCA9685, and make sure the V+ and ground wires are properly connected.
Usage Method
Install Library
In the Arduino IDE's Library Manager, search for and install the PCA9685 16-Channel PWM Driver Module Library
.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 17, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include "PCA9685.h"
PCA9685 pwmController(Wire);
PCA9685_ServoEval pwmServo1;
void setup() {
Serial.begin(115200); // 初始化串口
Wire.begin(); // 初始化I2C接口
pwmController.resetDevices(); // 复位i2c线上所有PCA9685设备
pwmController.init(); // 初始化模块
pwmController.setPWMFreqServo(); // 设置频率为标准的舵机50Hz频率
pwmController.setChannelPWM(0, pwmServo1.pwmForAngle(-90));//设置第0号通道的舵机旋转到180度
}
void loop() {
pwmController.setChannelPWM(0, pwmServo1.pwmForAngle(90));//第0个通道的舵机旋转到90度
delay(1000);
pwmController.setChannelPWM(0, pwmServo1.pwmForAngle(0));///第0个通道的舵机旋转到0度
delay(1000);
pwmController.setChannelPWM(0, pwmServo1.pwmForAngle(-90));///第0个通道的舵机旋转到180度
delay(1000);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42