Problem using MegaServo.h library.


I am trying to build hexapod using Arduino Mega. I have to control 18 servo motors. 3 in each leg of the robot. (Robot looks like the one in my profile display picture)

I am having a little problem, whenever i use pins from 22 onward motors do not work properly, when i connected same motors on different pins (don’t remember exactly but i think 22, 27, 30) the motor attached to pin 27 was working. there is no error in the code.
this is the code i wrote to test the working of 1 leg but only one motor out of three is working. i attached motors on pins 22, 25 and 28

#include <MegaServo.h>

int pos = 20;

MegaServo Servo_1; 
MegaServo Servo_2;
MegaServo Servo_3;

void setup()

void loop()

The first thing to check with servo issues is do you have an adequate external power supply for the servos similar to below? You can't power the servos directly from the arduino.

yes... i have external battery for the servos... they work fine when i connect them with pins 2-12

Was there ever a resolution to this? I am currently working on my own Hexapod, similar stats, and was running some trial and error today, finding more error than anything. Individually the servos would run fine on pins 9, 10, 11. I've yet to run individual tests on each leg's set of pins, but when trying all at once some servos worked, some did not. Also do you have any parts list or data on your bot, I'm interested in it. Thanks, Kyle Pittman