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


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

將機器人托架移動到指定的步數。零在電機原點位置,最大步數在遠離電機原點的軸端。

用法

axis.toStep(step)

參數

  • step:步數中的位置,home 等於 0

示例

#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();
  Serial.println("Press the Start Button to start the machine");
  while(!axis.ready()); // Wait for Start button to be pressed
  Serial.println("Current step: " + String(axis.getStep()));
  delay(1000);
  axis.toStep(1000);
  Serial.println("Current step: " + String(axis.getStep()));
}
void loop() {}

相關用法


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