Servo and Serial

Hi.

I solved the problem by throwing the servo library out the window and using PWM instead.
The Mega2560 has enough pins that support pwm for my project and this version seems to work with serial communication enabled.
The downside is that I can not use the full range of the servo movement. I can only adjust the angle between 0 and somewhat around 120 degrees instead of 180 like i could with the servo library.
This is okay for my project because i just have to move between 0 and 60 degrees.

I wrote a quick-and-dirty function for servo controlling:
ANGLE_0 and ANGLE_90 are the PWM values where the servo reached 90 or 0 degrees.
This values seem to depend on the servos. For my Hitec hs-303 Servos the values 75 and 180 work.
I am still waiting for the other servos to arrive so i can test this with 12 servos for real.

void writeServo(int pin, int angle) {
  int pwm=0;
  if((pin >= 2) && (pin <= 13) && (angle >= 0) && (angle <= 90)) {
      pwm = map(angle, 0, 90, ANGLE_0, ANGLE_90);
      analogWrite(pin,pwm);    
  }
}

-Alex