Skip to content

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

And I used it with the ULN2003 driver




//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  



Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

Leave a Reply

%d bloggers like this: