Servo86.write()

[Servo86]

描述

Set the target angle of the servo and rotate it to the target angle.

Please note that the servo will be activated immediately after calling this function. Please avoid turning the servo vigorously by hand to avoid injury or damage to the servo.

語法

servo.write(position)

參數

  • servo: The variable of Servo type.
  • Position: The target angle can be entered as an integer or a floating point number. When an integer is entered, such as 1500, the target position will be treated as a us unit, which is the position of the servo corresponding to the PWM pulse of 1500us. When a symbolic number is entered, such as 90.0, the target position will be treated as a “degree” unit, which is the 90 degree position of the servo.

回傳

範例

#include <Servo86.h> 
 
Servo myservo;
 
void setup() 
{ 
  myservo.attach(9);
  myservo.write(90.0);  // Let the servo turn to 90 degrees
} 
 
void loop() {} 

參考


函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール