write()

描述

設定伺服機目標角度,並且往目標角度轉動。

請注意,呼叫此函式後會讓伺服機立即出力,請避免以手大力轉動伺服機,以免受傷或損壞伺服機。

語法


servo.write(position)

參數

servoAIServo 型別的變數。

position:目標角度,輸入浮點數型別的數值,例如 90.0,目標位置為”度”單位,即伺服機的 90 度。

回傳

範例

#include <AIServo86.h> 

AIServoPort(ROBOTIS, AX12) bus;
AIServo myservo;

void setup() 
{ 
  bus.begin(Serial1, 1000000);
  myservo.attach(bus, 9);
  myservo.write(90.0);  // 讓伺服機轉到 90 度
} 

void loop() {} 

See also

attach()
read()


函式庫參考主頁面

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.