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.