ステッピングモータ(バイポーラ型)をArduinoで簡単に回す
1.はじめに
ステッピングモータをArduinoで回しました。モータドライバはこれを使いました。
2.配線時の注意
【モータドライバ端子への接続】
AOUT1 -> 黒 (ステッピングモータ端子)
AOUT2 -> 赤
BOUT1 -> 緑
BOUT2 -> 青
ーーーーーーーーーーーーーーーーーーーー
AIN1 -> D4 (Arduinoデジタルピン)
AIN2 -> D5
BIN1 -> D6
BIN2 -> D7
3.Arduinoコード
#include <Stepper.h> const int stepsPerRotate = 200;//ステップ数 = 360 / ステップ角 = 360 / 1.8 = 200 Stepper myStepper(stepsPerRotate, 4, 6, 5, 7); void setup(){ } void loop(){ myStepper.setSpeed(20); myStepper.step(100); delay(500); myStepper.step(-100); myStepper.setSpeed(30); myStepper.step(100); delay(500); myStepper.setSpeed(50); myStepper.step(-100); delay(500); }