For driving a stepper motor using Arduino you will need..
Components:
1: Arduino Uno (or any other type).Buy it from here
2: L298 Motor driver Module.Buy it from here
3: Stepper Motor Bi-polar.Buy it from here
4: Power Supply.(Make your own) or Buy it from here
- stepper motor A+
- stepper motor A-
- 12V jumper – remove this if using a supply voltage greater than 12V DC. This enables power to the on board 5V regulator
- Connect your motor supply voltage here, maximum of 35V DC. Remove 12V jumper if >12V DC
- GND
- 5V output if 12V jumper in place, ideal for powering your Arduino (etc)
- Leave this in place when using a stepper motor.
- IN1 to arduino pin 8.
- IN2 to arduino pin 9.
- IN3 to arduino pin 10.
- IN4 to arduino pin 11.
- Leave this in place when using a stepper motor.
- stepper motor B+
- stepper motor B-
Note 1: Connect arduino gnd to L298 gnd.
2: The key to successful stepper motor control is identifying the wires that is which one is which. You will need to determine the A, A-, B and B- wires.
Code:
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
}
void loop() {
// step one revolution in one direction:
myStepper.step(stepsPerRevolution);
delay(500);
// step one revolution in the other direction:
myStepper.step(-stepsPerRevolution);
delay(500);
}