PCA9865 not able to set servo to rotate

PCA9865 Arduino Uno
Am using one servo motor so connected to 5v pin of arduino to vcc.

Code i used from arduino examples:
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);
#define SERVOMIN 0 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 600 // this is the 'maximum' pulse length count (out of 4096)

// our servo # counter
uint8_t servonum = 0;

void setup() {
Serial.println("16 channel Servo test!");
Serial.print("servo number ");


pwm.setPWMFreq(50); // Analog servos run at ~60 Hz updates

void loop() {
// Drive each servo one at a time
if(servonum == 0) {
for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
pwm.setPWM(servonum, 0, pulselen);


servonum ++;
if (servonum > 0) servonum = 1;
After setting PWM i tried printing by getpwm(0) , result is o at all points.
21:25:33.277 -> 0
KIndly suggest.. is there problem with board?

Servo works fine since i tried connecting directly with arduino with servo library and rotating fine.

I2C scanner is detecting fine too!

Have you tried any of the example programs that come with the library? pwmtest for example.

Hello ,
The above code is from example from library for servo.
Just to be sure tried i2c scanner too.

Why set to 1? Isn't your servo in position 0?


Hello ,

Just to avoid running in loop. Not necessary as we have the condition of servonum =0.
Servo channel am using is 0

PIcture isn't easy to see but you don't seem to have any servo power connection to the PCA board. Just power to the electronics. See Overview | Adafruit PCA9685 16-Channel Servo Driver | Adafruit Learning System "The VCC pin is just power for the chip itself. If you want to connect servos or LEDs that use the V+ pins, you MUST connect the V+ pin as well."


1 Like

Hi Rossan,

if you have difficulties to write in english use google-translate.
You will get your problems solved faster if you write with more details

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.