attach()
描述
將 Servo
物件指定到一輸出腳位上。呼叫此函式後,指定腳位上的電壓將初始化為 LOW。
語法
servo.attach(pin)
servo.attach(pin, min, max)
參數
servo
:Servo
型別的變數。
pin
:腳位編號。
min
(可選):最小 PWM 脈波寬度,單位是微秒(us)。如果沒有輸入值或輸入值小於 450,內部將會用預設值 450 us 做為最小的 PWM 寬度。
max
(可選):最大 PWM 脈波寬度,單位是微秒(us)。如果沒有輸入值或輸入值大於 2800,內部將會用預設值 2800 us 做為最大的 PWM 寬度。
回傳
無
範例
#include <Servo86.h> Servo myservo; void setup() { myservo.attach(9); // 初始化 pin 9 為 Servo 腳位 } void loop() {}
See also
- attached()
- detach()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.