How to use a stepper motor with Arduino and its driver ULN2003
Hello there, 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/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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
//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 //Refer to SurtrTech.com #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); } |
Categories
Yassine View All
Automation and Electrical Engineer, Electronics amateur trying to share my little projects.
One thought on “How to use a stepper motor with Arduino and its driver ULN2003” Leave a comment ›