I am trying to control MG996R using code for a typical servo (SG90)
I used an external power supply, 5V,2A
I connected the servo signal line to Arduino slot 7,
servo positive to external power supply positive,
servo ground to external power supply ground,
while leaving the Arduino power supply and ground unconnected.
I tried the below code.
it works for SG90, while MG996R is not moving at all.
#include <Servo.h>
Servo myservo;
void setup()
{
myservo.attach(7); //pin 7 is the one control servo
}
void loop()
{
for (int pos=0; pos<=60; pos++)
{
myservo.write(pos);
delay(15);
}
}
Is it because the different servos need different code?
for
loop ... all you need ismyservo.write(45);
delay(1000);
myservo.write(135);
delay(1000);
... the servo will cycle between those two angles