angleMap()
描述
將伺服機的最大脈波寬度和最小脈波寬度對應到使用者自定義的角度。
在呼叫 attach() 後,預設會將的最小脈波寬度和最大脈波寬度分別對應到 0 度與 180 度,您可呼叫此函式改變對應的角度。
語法
servo.angleMap(min, max)
參數
servo:Servo 型別的變數。
min:伺服機最小脈波寬度要對應到的角度,值以浮點數表示,範圍介於 0.0 ~ 360.0 之間,單位:度。
max:伺服機最大脈波寬度要對應到的角度,值以浮點數表示,範圍介於 0.0 ~ 360.0 之間,單位:度。
回傳
無
範例
#include <Servo86.h>
Servo myservo;
void setup()
{
myservo.attach(9);
myservo.angleMap(0.0, 270.0); // 0 度為最小角度,270 度為最大角度
myservo.write(90.0); // 伺服機轉到 90 度
}
void loop() {}
See also
- attach()
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.
