I purchased a 20KG Digital Servo, DS3218MG with a Control Angle of 270° .
I am trying to get it to rotate with the following code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
int restingVal = 0;
int keyDown = 80;
void loop() {
int minutesDelay = 1;
Serial.print("Value");
Serial.println(restingVal);
delay(10000/2);
myservo.write(keyDown);
delay(500);
myservo.write(restingVal);
}
It makes a small "clicking" noise, but it never moves. I have tried:
- powering it from the arduino using a USB cable
- powering it using a power cord plugged into an electrical outlet
- powering it with 4 AA batteries in a battery pack (power from the battery pack to the servo with it's ground to the Arduino's ground and the arduino plugged into an outlet)
- using a 470uF capacitor and then tried a 680uF capacitor.
What am I doing wrong? Is there something else I could look at?
update: changed code to:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.write(60);
delay(2000);
myservo.write(120);
}
int restingVal = 0;
int keyDown = 80;
void loop() {
}
I get the same problem.
The power cord I'm using to connect the arduino is 12V DC 1A.
Here is a photo of the wiring in one configuration (with the battery pack and the wall outlet):
Orange wire goes to GND on arduino, the long green goes to ~9, yellow goes to VCC on battery pack.