Multiple Servo Motors not working with PCA9685 servo motor

Hi all,

For my humanoid robot, I am trying to connect 6 servo motors to the servo driver and for now I wanted to control two servo motors. For some reason my code doesn't seem to be working and I am not sure why this is the case? I am very new to Arduino code, so help would be appreciated.




Are you sure your code doesn't work? Post your code with code tags, not as picture. What servos do you use? What do you power the robot with? Just don't tell me, that with these little R6 batteries (size AA). Also post a wiring diagram.

Uh yes I am using the AA batteries for it and the MG90 servo motors. The code is here:

/*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 = 2; servo >= 0; servo-- ) {
srituhobby.setPWM(servo, 0, servoMAX);
Serial.println(servo);
delay(300);
}
}

do I need a bigger power supply? If so, how big. I am all new to this.

It looks like your servos are plugged in wrong. Brown should be GND and Yellow is PWM.

But what exactly does "doesn't seem to be working" mean? Does it compile? Does it do anything? If so what?

Steve

Thanks for pointing out the servos being plugged in wrong. What I meant by it doesn't seem to be working is the actually code that I upload into the Arduino UNO. I have done a code to move servo 0 and 2, but they are not moving. That is the main issue here.

The servos wont move when they're plugged in wrong. If it still doesn't work when you correct that have you tried the Adafruit example program "servo"? If nothing works with that you probably have some connections wrong.

4 x AA batteries should be good enough to run 2 servos but you'll probably need something better to run six.

Steve

Why

the frequency is 60Hz? Working frequency on PWM signal for servo motor is 50Hz.
The robot looks big to me. Are these servos strong enough? For power supply I would recommend 2x18650 (in serial) and step down DC DC converter for 5 volts - for Arduino Uno and all servo motors. Also in your photo it seems that you have connected the power supply of PCA9685 incorrectly - an orange cable from Arduino goes to IN +. You must wired Arduino 5 volts to the Vcc on PCA9685.

Yes, I have tried the example code that was given called 'servo' and that did not work as well.

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