How to use a stepper motor with Arduino and its driver ULN2003

Hello everybody, this post is about using a Stepper motor with an Arduino by using one of its drivers, which is ULN2003, it’s a driver that’s widely used, because it’s cheap and simple.

The stepper motors are used in applications and projects that requires high torque rotations and precise rotation and position.

Here I used the motor 28BYJ-48, you can check its datasheet  http://robocraft.ru/files/datasheet/28BYJ-48.pdf

And I used it with the ULN2003 driver

Wiring:

 

Code:

//This code is for using a stepper motor with it's driver ULN2003

//The code turns the stepper in clockwise by 200 step then in counter clockwise by 400 step 

//By SurtrTech


#include <Stepper.h>  //Stepper library


int StepNum=2050;   //Number of your motor steps check the datasheet of your motor the replace it if necessary


Stepper SurtrStepper(StepNum,9,11,10,6); //Defining the stepper, you should wire IN1-2-3-4 from the driver in (respectivly) d6 d9 d10 d11 from arduino

                                         //Or change the pins correctly

                     

void setup() {

  SurtrStepper.setSpeed(9); //Speed of the motor 9 is most used

}


void loop() {

  SurtrStepper.step(200);  //Positive and negative changes the direction  

  SurtrStepper.step(-400);


}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: