Sunday, 12 March 2017

Arduino Stepper motor interfacing.


 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

 Connections:-



  1.  stepper motor A+
  2.  stepper motor A-
  3. 12V jumper – remove this if using a supply voltage greater than 12V DC. This enables power to the on board 5V regulator
  4. Connect your motor supply voltage here, maximum of 35V DC. Remove 12V jumper if >12V DC
  5. GND 
  6. 5V output if 12V jumper in place, ideal for powering your Arduino (etc)
  7.  Leave this in place when using a stepper motor. 
  8. IN1 to arduino pin 8.
  9. IN2 to arduino pin 9.
  10. IN3 to arduino pin 10.
  11. IN4  to arduino pin 11.
  12.  Leave this in place when using a stepper motor.
  13.  stepper motor B+
  14.  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);
}