当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Arduino Arduino_EMBRYO_2 - drawCircle()用法及代码示例


用 EMBRYO 2 的两个轴绘制一个圆。

用法

robot.drawCircle(centerX,
              centerY,
              radius)

参数

  • centerX : 圆心位置的 X 轴坐标,单位为厘米。
  • centerY : 圆心位置的 Y 轴坐标,单位为厘米。
  • radius:以厘米为单位的圆半径大小。

示例

#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);

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

  robot.begin();

  robot.setLengthXY(45, 25);
  
  Serial.println("Press the Start Button to start the machine");
  while(!robot.ready()); 
  
  Serial.println("Moving the robot to the initial XY position ...");

  robot.toPositionXY(15, 15);
  
  Serial.println("Press the forward button to continue ...");
}
void loop() {
  if(axisX.readBtnForward()){
    robot.drawCircle(15, 15, 5);
  }
}

相关用法


注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 Arduino_EMBRYO_2 - drawCircle()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。