Syntax
VMUINT8 attach(
    int pin
);
ContentsIndex
PreviousUpNext
Servo::attach Method (int)
Servo Class | Example
Syntax
VMUINT8 attach(
    int pin
);
Description

Attaches a servo motor to a digital pin. Only digital pins supporting PWM (D3, D9) can use this function.

Parameters
Parameters 
Description 
int pin 
The pin which needs servo attachment. 
Returns

The channel number, or  

0: Failed.

Example
#include <Servo.h>
 
Servo myservo;
 
void setup()
{
  myservo.attach(9);
}
 
void loop() 
{
  
}
File

Servo.h

Class