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

Attaches 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. 
int min 
(Optional)lower bound of PW, ms; PWM when servo motor is at 0 degree (default: 544). 
int max 
(Optional)upper bound of PW, ms, PWM when servo motor is at 180 degrees (default: 2400). 
Returns

Channel number or  

0: Failed.

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

Servo.h

Class