#include <AccelStepper.h>
//#include <MultiStepper.h> // 멀티 여러모터 사용시
//#include <Stepper.h> = 기본 라이브러리
#include <value.h>
#include <My_Arduino_GPIO_Lib_V1_8.h>
#define if_type 4
// IN1 -> IN3 -> IN2 -> IN4
AccelStepper st_motor(if_type, 8, 10, 9, 11); // a, b, /a, /b
const int step_reg = 2038; // 레졸레이션
void setup() {
// put your setup code here, to run once:
st_motor.setMaxSpeed(1000.0);
st_motor.setAcceleration(50.0);
st_motor.setSpeed(200); //Speed
st_motor.moveTo(2035);
}
void loop() {
// put your main code here, to run repeatedly:
// 실습2 = 가감속 제어하기 = 별도 라이브러리 설치해야
// 방향바꾸기
if(st_motor.distanceToGo() == 0)
st_motor.moveTo(-st_motor.currentPosition());
// 모터 동작시킴
st_motor.run();
// 실습 1 = 기본돌리기 = 기존 라이브러리 사용
// cw
// st_motor.step(step_reg);
// delay(1000);
// // CCW
// st_motor.step(-step_reg);
// delay(1000);
}