Electronic – arduino – Servo not working with Arduino

arduinoservo

I've connected a servo(AS-18 acoms) to my arduino and I've uploaded the sweep example onto it. But nothing happens . Here's a pic.
I've connected the positive terminal of the servo to 5V on the board, negative to ground and the pulse wire to digital pin 9. Is that right?
enter image description here

#include <Servo.h> 

Servo myservo;  // create servo object to control a servo 
            // a maximum of eight servo objects can be created 

int pos = 0;    // variable to store the servo position 

void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 


void loop() 
{ 
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
 } 
} 

Best Answer

The AS-18 generates 6.5 kg-cm (0.6374 N-m) torque, and rotates at about 180 degrees per second, unloaded. This works out to an estimated power rating of 2 Watts (from calculator here).

Assuming 75% efficiency under no load, the power consumption at start of motion (when it is overcoming inertia) is thus around 2.67 Watts.

At 5 Volts and 2.67 Watts, current required is 534 Milliamps. This is above the current an Arduino's 5 Volt line can provide. It appears from the question that the Arduino's power source is USB: The USB port limitations of 500 mA reduce the available current to the servo, as the Arduino board itself will consume some of the available 500 mA.

Ideally, the power pin of the servo needs to be supplied by a separate 5 (or 6) Volt DC supply, with the ground of this external supply tied to the Arduino ground. 4 AA alkaline cells should suffice.

If this is not viable, then one could try to power the Arduino board with an external 7 to 12 Volt 1 Ampere or better DC supply, through the DC-in barrel jack on the board.

Do note, though, that the Arduino has a 500 mA resettable fuse on board. While the fuse should not blow on a momentary 500 mA load such as when the servo begins to rotate, if the servo is used to drive a significant load, the sustained current required may exceed the fuse trip point. Hence such an arrangement is marginal at best.

This brings us back to the recommendation of externally powering the servo.