stop()

描述

停止伺服机的转动。

呼叫此函式后,伺服机会在当前的位置上立即停止。此函式的行为和 pause() 不同,您无法透过 resume() 让伺服机恢复转动,必须重新设定目标位置并呼叫 run(),或者呼叫 write()writeMicroseconds() 才能让伺服机再次转动。

请注意,伺服机在停止状态仍会出力,此时请勿用手大力转动伺服机,否则容易造成伺服机损坏。

语法


servo.stop()

参数

servoServo 型别的变数。

回传

范例

#include <Servo86.h> 

Servo myservo;

void setup() 
{ 
  myservo.attach(9);
  myservo.write(1500);  // 将伺服机转到 1500us 初始位置
  myservo.run(); // 启动伺服机
  delay(100);

  myservo.setPosition(1800, 3000); // 设定伺服机的目标角度:1800us,时间:3 秒
  myservo.run();
  delay(2000); // 让伺服机转动 2 秒
  myservo.stop(); // 停止伺服机
} 

void loop() {} 

See also

setPosition()
run()
pause()
resume()


函式库参考主页面

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.