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


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

將 EMBRYO 2 教育模塊化機器的 X 和 Y 托架移動到每個軸上的指定步數。零在電機原點位置,最大步數在遠離電機原點的軸端。

用法

robot.toStepXY(stepX, stepY)

參數

  • stepX:步數中的 X 軸位置,原點為零
  • stepY:步數中的 Y 軸位置,home 等於 0

示例

#include <Arduino_EMBRYO_2.h>

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

StepMotor axisY(2, A5, 10, 11, 8, 9, A3, A4, 2, 12);

Embryo robot(axisX, axisY, 2, 12);

unsigned long stepNumX = 0, stepNumY = 0;

void setup() {
  Serial.begin(115200);
  while (!Serial) {};

  robot.begin();

  Serial.println("Press the Start Button to start the machine");
  while(!robot.ready());
}
void loop() {
  Serial.println("Enter the number of the step for X-axis: ");
  while((Serial.available() <= 0)){};
  stepNumX = Serial.parseInt(); 

  
  Serial.println("Enter the number of the step for Y-axis: ");
  while((Serial.available() <= 0)){};
  stepNumY = Serial.parseInt(); 

  robot.toStepXY(stepNumX, stepNumY);
}

相關用法


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