Introduction: 28BYJ-48 Stepper Motor

About: Electronics, Systems, Programming, Tech, Geeky stuff.... all are my <3

Assuming you have this type of stepper motor :D and you wonna run it.. you may face two problems in your


  1. Using the arduino stepper library to drive it you found out that the 28BYJ-48 stepper motor
    is only rotating in one direction & when you flip the direction it doesn't respond and continue in that direction ( seems its ignoring your commands OOps :P ).

  2. You found out that you want your arduino to do something else while its rotating that motor and not
    wait till it finish to do so.

    So so in this little instra i will explain the reason for behind THESE


Step 1: Why !

The first issue is because not every thing in this world is the same, also stepper motors are not the same some are Bipolar some are Unipolar.. wait a second what does that mean :/ ?

Well you dont have really to care about deep stuff other than its a difference in basic architecture

and difference in switching sequence... and what is the switching sequence ?

If you have read a basic description about stepper motors.. they just work on by switching the coils on off on off one by one or more than one at a time which create a magnetic field that let the metallic part to rotate, so the sequence is like if we have 4 coils .. how we will trigger them at a time.. so this info shall come in product description or just GOOGLE it.. (in the uploaded pics there are two types of sequences) ,.... any way.

So this 28BYJ-48 sequence is gonna be like

1000, 1100, 0100, 0110, 0010, 0011, 0001, 1001 at a time to cause a step

since arduino library could make our stepper not to rotate because of difference in sequences that is the reason of one direction :D

The second issue is that we get into a locked loop to perform the rotation till it finish then the control goes back to the microcontroller ...

Wonna solve these problems go to the next step... >

Step 2: Solution!

28BYJ48 is a simple library i wrote to fix the problem for me,, so i wanted to share it ..

this library is easy to use .. it will let you drive your motor in two directions.. also you can let the program flow while you are driving your motors .. tadaa.

you may think.. how can i tell it to rotate 360 degrees or less or more :/ shall i calculate it all the time in my mind..

the answer is noOO.. if you wonna use degrees, radians or what ever unit you have in your mind other than STEPS

you just write a custom function that will do the conversion from your unit to the motor unit :D implementing your mathematical accuracy,,,

for example:

to give the angle in degrees you may use this way:

long f1(long x){return x*motor.steps_per_rev/360; 

or this way:

long f1(long x){return map(x, 0, 360, 0, motor.steps_per_rev); 

and then pass that function to the motor


Link to the library is here