Servo strange behavior

I'm trying to move 2 servos of a robotic arm just using some servo.write() to change the angles and see how the arm behaves. The code works but when I upload the Arduino code to see if they will move to the positions i sent them, before moving into those positions this one motor loses all power and the arm starts going slowly down and the it moves to over 120º before going to the angles that I sent it to. No matter if I write 20º, 30º, 40º or 50º before moving to this angle the motor always loses power and goes all the way to a very high angle before moving into the right angle while the other motor is normal.

I'm only using a 5V/5A power supply with common ground with arduino and basic codes just to see the positioning of the arm. When I was just working with that motor connected direct to the Arduino and testing angles this motor didn't show any strange behavior.

#include <Servo.h>

int servoPin0 = 2;
int servoPin1= 3;
int servomotorPosition0=90;
int servomotorPosition1=50;
int dt =4000;

Servo myServo0;
Servo myServo1;

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);
myServo0.attach(servoPin0);
myServo1.attach(servoPin1);

}

void loop() {

// put your main code here, to run repeatedly:

myServo0.write(servomotorPosition0);
delay(dt);
myServo1.write(servomotorPosition1);
delay(dt);


}

Any help would be apreciated. Thanks.

Please post a schematic.

Schematic

1 Like

Forgot to say the servos are MG996R the one that is normal and MG995 the one that is strange.

... and Arduino Vin connects to 5V+?

Here is a simulation to compare... or paste your code in and see if it works.

If you are using a breadboard to connect the servos to the power supply, that is a problem. Either solder power connections, or use a servo power distribution PCB.

1 Like

No Arduino Vin is not connected to anything. Arduino is being powered by a 12V power cable.

1 Like

Yes. I was using a breadboard and it seems that was the problem. Using alligator cables to connect the servos to the power supply made the servo work correctly.

Thanks

1 Like

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