I am using the Mega to control 18 servos. Here is some of the code:
const int LEG_COUNT = 6;
const int servos_per_leg = 3;
enum leg_id { R1, R2, R3, L3, L2, L1 };
// Servo pins.
const int servo_pins[][servos_per_leg] = {{42, 43, 44}, // R1
{34, 35, 37}, // R2
{26, 27, 28}, // R3
{22, 23, 24}, // L3
{30, 32, 33}, // L2
{38, 39, 40}}; // L1
// create servo objects to control servos.
for (int i = 0; i < (LEG_COUNT); i++)
{
Servo sx; // New servo object.
servos[i].coxa = sx; // Add to array.
Servo sy; // New servo object.
servos[i].femur = sy; // Add to array.
Servo sz; // New servo object.
servos[i].tibia = sz; // Add to array.
servos[i].coxa.attach(servo_pins[i][x]); // Attach servo to pin.
servos[i].femur.attach(servo_pins[i][y]); // Attach servo to pin.
servos[i].tibia.attach(servo_pins[i][z]); // Attach servo to pin.
}