Notifications
Clear all

Need help with getting servos working with the AdafruitPCA9685 module.

8 Posts
3 Users
0 Reactions
206 Views
(@slamer)
Member
Joined: 4 months ago
Posts: 11
Topic starter  

Hi,

I ran across this video making animatronics using blender to animate them and export the animation to an Arduino.

There are links for the sketch examples on the creator's github here.
https://github.com/timhendriks93/blender-servo-animation-arduino

for testing I'm specifically working with this example sketch before I work on my own animatronic.
https://github.com/timhendriks93/blender-servo-animation-arduino/tree/main/examples/AdafruitPCA9685

I'm very certain I have everything connected properly and the sketch uploads successfully but I get no movement by the servos.

I don't know what I am doing wrong and I'm sure it is on my end. I'm new to Arduino so I'm sure there is something I'm missing and most likely something pretty simple.

What will be the most useful information I can provide to get help in figuring this out?

thanks 


   
Quote
(@aliarifat)
Member
Joined: 11 months ago
Posts: 99
 

I think it will be better if you share the exact code that you're running. 


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 6 years ago
Posts: 1134
 

I'm assuming you have it wired as illustrated in the wiring diagram on GitHub?

If so, then you need to start troubleshooting. Here is how I would go about it:

  • Check the power supply. If you're wiring it as in the GitHub diagram, it should be matched to the servo supply voltage with a decent amount of current capability. Not knowing what servos you are using makes it difficult to give you exact specs.
  • If the power supply is good, I would write a quick sketch to drive the servos with the PCA9685.  My last video was about servo motors; the PCA9685 demo sketch I showed would work.
  • If it won't work with the demo sketch, it certainly won't work with the "Blender Servo Animation" (which is totally cool, by the way — you've introduced me to something new—thanks!!).  At that point, I'd be rechecking wiring or even swapping the PCA9685 (use the I2C scan sketch in the example code to see if you can see the PCA9685 on the I2C bus). Hopefully it won't come to that.

 

I hope that gets you started. Perhaps you can post details regarding the exact servo motors and power supply you're using. I mentioned the power supply first, as that's the source of most servo motor issues.

😎

Bill 

This post was modified 2 weeks ago by DroneBot Workshop

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
(@slamer)
Member
Joined: 4 months ago
Posts: 11
Topic starter  

So maybe this will help - @bill, this will show that I believe I did wire correctly according to the diagram. See the images below.

Microcontroller - an official Arduino Nano - not a clone.
 
HiLetgo PCA9685 16 Channel 12-Bit PWM Servo Motor Driver IIC Module (from Amazon)
 
Power source - 5v SBEC  (specifically this one used for RC plane servos. I power off a 24v battery and this reduces it to 5v.  https://hobbyking.com/en_us/turnigy-5a-8-40v-sbec-for-lipo.html?srsltid=AfmBOoqixX4H1oxgqBHJv8xZGl5UO9LxAwjbV4pY7AoczR7CcTMyHb0F )
 
IDE - Arduino IDE 2.3.6
 
Set up using this example.
 
@aliarifat Link to the the actual .ino
 
Wire set up
Black - GND (module board) to GND (Nano)
Green - SCL (module board) to TX1 (Nano)
Blue - SDA (module board) to TX0 (Nano)
Red - VCC (module board) to 5v (Nano)
 
Following this image from the Github
image

Module board

image
 
Arduino Nano side. Trying to show both pin side and printed PCB side.

image
image

Posted by: @dronebot-workshop

Check the power supply. If you're wiring it as in the GitHub diagram, it should be matched to the servo supply voltage with a decent amount of current capability. Not knowing what servos you are using makes it difficult to give you exact specs.

I listed the power supply above. Its the 5v SBEC coming from a 24v power tool battery.

 

Posted by: @dronebot-workshop

If the power supply is good, I would write a quick sketch to drive the servos with the PCA9685.  My last video was about servo motors; the PCA9685 demo sketch I showed would work.

This one right?

cool, I will watch it tonight.

 

I will double check wiring. and test servos and test some demo sketches and see what happens.

 

I did reach out to the creator again. Hopefully he has some ideas too. 

 

Thanks for the help. I'll keep you all posted.


   
ReplyQuote
(@slamer)
Member
Joined: 4 months ago
Posts: 11
Topic starter  

Update.

I watched your video on servos. Great video and very helpful.

I tested all the servos (I have 10) with the servo tester and power supply I listed above. They all work.

I set up and tested your (Bill) Arduino test code with a single servo connected to the Nano.
This worked fine - as expected. So I know the Nano is working.

/*
  Arduino Uno Servo Motor Demo
  arduino-servo.ino
  Sweeps servo motor 180 degrees in both directions
  Servo connected to pin D9
  
  DroneBot Workshop 2025
   https://dronebotworkshop.com 
*/

// Include Arduino Servo Library
#include <Servo.h>

// Create servo object and set position
Servo myServo;
int pos = 0;

// Define Servo pin
#define SERVO_PIN 9

void setup() {

  // Attach the servo
  myServo.attach(SERVO_PIN);
}

void loop() {

  // Sweep from 0 to 180 degrees
  for (pos = 0; pos <= 180; pos += 1) {
    // Set position
    myServo.write(pos);
    // Wait for servo to reach position
    delay(15);
  }

  // Sweep from 180 to 0 degrees
  for (pos = 180; pos >= 0; pos -= 1) {
    // Set position
    myServo.write(pos);
    // Wait for servo to reach position
    delay(15);
  }
}

Then I tested the code for the PCA9685 Module
Because I'm using the Nano and not the Seeeduino, I had to use Pins A4 and A5 for the I2C communications.

To clarify, this code, from your video, which also worked in. All four servos did their thing. So I know the PCA9685 board is working.

/*
  PCA9685 Servo Demo
  pca9685-demo.ino
  Uses Adafruit Adafruit_PWMServoDriver Library
  Uses Seeeduino XIAO ESP32-S3 module
  Demonstrates operation of PCA9685 16-Channel 12-Bit PWM module
  
  DroneBot Workshop 2025
   https://dronebotworkshop.com 
*/

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

// Initialize with default I2C address (0x40)
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

// Servo parameters (adjust based on your servos)
#define SERVO_MIN 150  // Minimum pulse length count (out of 4096)
#define SERVO_MAX 600  // Maximum pulse length count (out of 4096)

void setup() {

  //Start PWM
  pwm.begin();
  // Set PWM frequency to 50Hz (standard for servos)
  pwm.setPWMFreq(50);

  delay(10);
}

// Function to set angle (0-180) for a servo on specified channel
void setServoAngle(uint8_t channel, int angle) {
  // Map angle to pulse length
  int pulse = map(angle, 0, 180, SERVO_MIN, SERVO_MAX);
  pwm.setPWM(channel, 0, pulse);
}

void loop() {

  // Demonstrate controlling four servos
  for (int i = 0; i < 4; i++) {

    // Sweep servo on channel 0 from 0 to 180 degrees
    for (int angle = 0; angle <= 180; angle += 5) {
      setServoAngle(i, angle);
      delay(50);
    }

    // Sweep back from 180 to 0 degrees
    for (int angle = 180; angle >= 0; angle -= 5) {
      setServoAngle(i, angle);
      delay(50);
    }
  }
}

 

Now I just need to figure our what I'm doing wrong with the animatronics setup.

Would anyone be willing to test it on their end?

I did notice that he uses the TX and RX pins instead of A4 an A5. Although I think I tried that too and it still did not work.

 

I'll try and test it again and let you know.


   
ReplyQuote
(@slamer)
Member
Joined: 4 months ago
Posts: 11
Topic starter  

OK! Another update.
Instead of using the SCL to RX0 and SDA to TX1 as shown in the wire diagram on the animatronics github, I changed it to using A4 and A5 and the servos moved!

I'll reach out to him and let him know.


   
ReplyQuote
(@aliarifat)
Member
Joined: 11 months ago
Posts: 99
 

@slamer did you also change the default code accordingly?


   
ReplyQuote
(@slamer)
Member
Joined: 4 months ago
Posts: 11
Topic starter  

Posted by: @aliarifat

@slamer did you also change the default code accordingly?

Forgive my ignorance, but what would be the default code you are referring to?

Since it was a matter of using different pins I didn't need to change any code.

I did reach out to the creator about the pin and he mentioned the board he was using was different so the diagram was not accurate. 

 


   
ReplyQuote