release()

描述

釋放正在運作中的伺服機。請注意,此函式與 pause() 的行為類似,但有相同和不同的地方,相同的地方在於:伺服機都會在當前的位置上停止轉動,且停止的伺服機仍會出力,此時請勿大力用手轉動伺服機,否則容易造成伺服機損壞,不同之處在於:呼叫此函式後會清除曾經設定過的轉速、目標角度等等資訊,所以後面若接著呼叫 resume() 將無法恢復伺服機往目標位置轉動。

語法


servo.stop()

參數

servoServo86 型別的變數。

範例

#include <Servo.h> 

Servo myservo;

void setup() 
{ 
  myservo.attach(9);
  myservo.setPosition(1500);  // 設定伺服機的目標位置:1500us
  myservo.run(); // 啟動伺服機
  delay(100);
} 

void loop()
{
  myservo.setPosition(1800, 3000); // 設定伺服機的目標位置:1800us,時間:3 秒
  myservo.run();
  delay(1000); // 讓伺服機轉動 1 秒
  myservo.stop(); // 將伺服機停止轉動
} 

See also

attach()
setPosition()
pause()
resume()


函式庫參考主頁面

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.