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.