當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino Arduino_EMBRYO_2 - setSpeed()用法及代碼示例

根據脈衝之間的時間設置電機的速度,以毫秒為單位。這個值是電機走半步的時間。最大速度為 200 毫秒,最小速度為 25000 毫秒。默認速度值為 200 毫秒。

用法

axis.setSpeed(speed)

參數

  • speed :脈衝之間的時間(以毫秒為單位)(默認為 200)

示例

#include <Arduino_EMBRYO_2.h>

StepMotor axis(1, A5, 5, 6, 3, 4, A2, A1, 2, 12);

void setup() {
  Serial.begin(9600);
  while (!Serial) {};
  axis.begin();
  axis.startWithoutHomming();  // Initialize the motor without homing procedure
  axis.setSpeed(7000); // The motor moves slower
  for (int i = 0; i < 20000; i++)axis.moveForward();
  delay(1000);
  axis.setSpeed(); // The motor moves in the default speed, 200 milliseconds
  for (int i = 0; i < 20000; i++)axis.moveBackward();
  delay(1000);
  axis.stop();
}
void loop() {}

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 Arduino_EMBRYO_2 - setSpeed()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。