我想找...

搜尋

分享

目錄

servo.write()

[Servo]

描述

Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement).

語法

Servo myservo;

servo.write(angle);

參數

  • servo: a variable of type Servo
  • angle: the value to write to the servo, from 0 to 180

範例

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

參考


函式庫參考主頁面

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

發表評論

上部へスクロール