我想找...

搜尋

分享

目錄

servo.writeMicroseconds()

[Servo]

描述

Writes a value in microseconds (uS) to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft. On standard servos a parameter value of 1000 is fully counter-clockwise, 2000 is fully clockwise, and 1500 is in the middle.

Note that some manufactures do not follow this standard very closely so that servos often respond to values between 700 and 2300. Feel free to increase these endpoints until the servo no longer continues to increase its range. Note however that attempting to drive a servo past its endpoints (often indicated by a growling sound) is a high-current state and should be avoided.

Continuous-rotation servos will respond to the writeMicrosecond() function in an analogous manner to the write function.

語法

Servo myservo;

servo.writeMicroseconds(uS);

參數

  • servo: a variable of type Servo
  • uS: the value of the parameter in microseconds (int)

範例

#include <Servo.h> 
 
Servo myservo;
 
void setup() 
{ 
  myservo.attach(9);
  myservo.writeMicroseconds(1500);  // set servo to mid-point
} 
 
void loop() {} 

參考


函式庫參考主頁面

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

發表評論

上部へスクロール