코드
https://dronebotworkshop.com/stepper-motors-with-arduino/
Stepper Motors with Arduino – Bipolar & Unipolar
Learn how to control bipolar and unipolar stepper motors with an Arduino using drivers like the ULN2003, L298N and A4988.
dronebotworkshop.com
/*
Stepper Motor Demonstration 2
Stepper-Demo2.ino
Demonstrates Two 28BYJ-48 Unipolar Steppers with ULN2003 Driver
Uses Accelstepper Library
DroneBot Workshop 2018
https://dronebotworkshop.com
*/
// Include the AccelStepper Library
#include <AccelStepper.h>
// Define Constants
// Define step constants
#define FULLSTEP 4
#define HALFSTEP 8
// Define Motor Pins (2 Motors used)
#define motorPin1 8 // Blue - 28BYJ48 pin 1
#define motorPin2 9 // Pink - 28BYJ48 pin 2
#define motorPin3 10 // Yellow - 28BYJ48 pin 3
#define motorPin4 11 // Orange - 28BYJ48 pin 4
#define motorPin5 4 // Blue - 28BYJ48 pin 1
#define motorPin6 5 // Pink - 28BYJ48 pin 2
#define motorPin7 6 // Yellow - 28BYJ48 pin 3
#define motorPin8 7 // Orange - 28BYJ48 pin 4
// Define two motor objects
// The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper2(FULLSTEP, motorPin5, motorPin7, motorPin6, motorPin8);
void setup()
{
// 1 revolution Motor 1 CW
stepper1.setMaxSpeed(1000.0);
stepper1.setAcceleration(50.0);
stepper1.setSpeed(200);
stepper1.moveTo(2048);
// 1 revolution Motor 2 CCW
stepper2.setMaxSpeed(1000.0);
stepper2.setAcceleration(50.0);
stepper2.setSpeed(200);
stepper2.moveTo(-2048);
}
void loop()
{
//Change direction at the limits
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
stepper1.run();
stepper2.run();
}
https://dronebotworkshop.com/stepper-motors-with-arduino/
참고
https://www.youtube.com/watch?v=0qwrnUeSpYQ
A4988 드라이버로 스텝모터 제어하기-아두이노
A4988 스텝모터 드라이버를 이용하여 스텝모터를 제어해 보겠다 아두이노 라이브러리 없이도 할 수 있겠지...
blog.naver.com
[아두이노] 스테퍼 모터 2개 이상 멀티 컨트롤 하는 방법
현재 제작하는 RC카 구조의 카메라 슬라이더 장착하려고 stepper motor 2개를 동시에 제어하는 부분을 찾아보고 있습니다. 아두이노 기본라이브러리는 동시 제어가 안됩니다. 구글링으로 AccelStepper
www.zenez.org
AccelStepper라이브러리로 스테핑모터 제어하기
스테핑모터를 기본적으로 제어하는 것은 방향, 스텝진행 그리고 스템진행시 대기시간 조절에 의한 속도조절이다. 그런데 스테핑모터로 기계장치를 움직일 때 정지상태에서 갑자기 속도를 높이
makernambo.com
'만들기 > 아두이노' 카테고리의 다른 글
1602A LCD 디스플레이 가변저항 표시하기 (0) | 2022.09.08 |
---|---|
DC - DC 컨버터 (0) | 2022.09.01 |
아두이노를 이용한 워터펌프 (pwm 신호 제어) (0) | 2022.08.27 |
온도조절 펌프 만들기 ( 아두이노, 펠티어, 열선) (0) | 2022.08.13 |
포텐셔미터(가변저항)으로 360도 서보모터 방향 속도 조절하기 (0) | 2022.07.14 |