uint8_t PWMServo::attach(int pinArg, int min, int max) { if (pinArg != 9 && pinArg != 10) return 0; min16 = min / 16; max16 = max / 16; pin = pinArg; angle = NO_ANGLE; digitalWrite(pin, LOW); pinMode(pin, OUTPUT); if (!attached9 && !attached10) seizeTimer1(); if (pin == 9) { attached9 = 1; TCCR1A = (TCCR1A & ~_BV(COM1A0)) | _BV(COM1A1); } if (pin == 10) { attached10 = 1; TCCR1A = (TCCR1A & ~_BV(COM1B0)) | _BV(COM1B1); } return 1; }
uint8_t Servo::attach(int pinArg, int min, int max) { if (pinArg != servoAPin && pinArg != servoBPin) return 0; min16 = min / 16; max16 = max / 16; pin = pinArg; angle = NO_ANGLE; digitalWrite(pin, LOW); pinMode(pin, OUTPUT); if (!attachedA && !attachedB) seizeTimer1(); if (pin == servoAPin) { attachedA = 1; TCCR1A = (TCCR1A & ~_BV(COM1A0)) | _BV(COM1A1); } if (pin == servoBPin) { attachedB = 1; TCCR1A = (TCCR1A & ~_BV(COM1B0)) | _BV(COM1B1); } return 1; }