angleMap()

描述

将伺服机的最大脉波宽度和最小脉波宽度对应到使用者自定义的角度。

在呼叫 attach() 后,预设会将的最小脉波宽度和最大脉波宽度分别对应到 0 度与 180 度,您可呼叫此函式改变对应的角度。

语法


servo.angleMap(min, max)

参数

servoServo 型别的变数。

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.