Servo.attach()

Dear Sir,

I use servo library. When run servo.attach(2), It will run the default Pulse width (1500us) in Servo.h.

The servo motor will move 100 degrees,

We don't want to move during attach(), such that I change

Servo::Servo()
{
if( ServoCount < MAX_SERVOS) {
this->servoIndex = ServoCount++; // assign a servo index to this instance
servos[this->servoIndex].ticks = usToTicks(0); //DEFAULT_PULSE_WIDTH);
// store default values - 12 Aug 2009
}
else
this->servoIndex = INVALID_SERVO ; // too many servos
}

Some motors don't move, but other cannot do.

How can I fix this problem.

Thanks

Best regards,
Tsui Ka Ping

Did you know you can do a write before the attach?

Thanks. I don't know, but don't want to rotate the servo motor in setup procedure. If the servo motor is in 120 degree in idle state, it will keep 120 degree after power up.

Thank you for your help

There is no way for the Arduino to know what angle a servo is at before the Arduino issues a servo.write() command.

Perhaps you could have a formal shut-down function that ensures the servos go to known positions. If you had sent the servo to 120deg before shutdown you could use servo.write(120) in setup() to ensure the initial position was maintained.

However there is no guarantee that a human hand won't move the servos while the Arduino is off.

...R