Please help
I'm trying to program an MG996R to rotate from 0 degrees to 90 degrees, stop for 5 seconds, rotate back to 0 degrees and end program. I have tried a few codes found on the internet but none give me my desired output. I am using an Arduino Uno to program my motor and my motor is being powered by an external source proving 5V at 2amps.
Any help will be appreciated thanks
/*
Arduino Servo Test sketch
*/
#include <Servo.h>
Servo servoMain; // Define our Servo
void setup()
{
servoMain.attach(10); // servo on digital pin 10
}
void loop()
{
servoMain.write(45); // Turn Servo Left to 45 degrees
delay(1000); // Wait 1 second
servoMain.write(0); // Turn Servo Left to 0 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo back to center position (90 degrees)
delay(1000); // Wait 1 second
servoMain.write(135); // Turn Servo Right to 135 degrees
delay(1000); // Wait 1 second
servoMain.write(180); // Turn Servo Right to 180 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo back to center position (90 degrees)
delay(1000); // Wait 1 second
}
this code if off the internet and seems to work the best out of the other codes that I have tried