servo.attach

hi, everyone. Can anyone tell me why servo.attach() is defined in void setup(), and not globally? How come it still works in void loop()? According to the Arduino tutorial on LEDs at the very last part, servo.attach() should not be called in void setup() because it is not global to void loop().

It's not "defined" though, it's an action. It's like if you do a pinMode() in setup(), the pin's still pinMode()-ed when you digitalWrite() it later in loop().

According to the Arduino tutorial on LEDs at the very last part, servo.attach() should not be called in void setup() because it is not global to void loop().

Can you link to and/or quote from that please?

The servo object is defined globally so it does not matter where the attach() is done the servo object will still be available globally and the servo object will have a private variable holding the pin number to be used.

According to the Arduino tutorial on LEDs at the very last part,

Can you please provide a link to this advice