arduino-libraries / Servo

Servo Library for Arduino
http://arduino.cc/
GNU Lesser General Public License v2.1
233 stars 251 forks source link

attach(pin) returns 0 #85

Closed BanksySan closed 2 years ago

BanksySan commented 2 years ago

The documentation says that .attach(pin) should return the pin assigned or 0 in the case of a failure.

When I check the returned value it's always 0, regardless of failure:

#include <Servo.h>

Servo servo;

void setup() {
  Serial.begin(9600);
  byte b = servo.attach(2);
  while(!Serial) { ; }
  Serial.println("Ready\n=====");
  Serial.println("Pin attached:  " + String(b));
}

Output:

Ready=====
Pin attached: 0