Non-blocking Stepper motor


I need to have my stepper motor continuously run while my arduino takes care of doing other tasks.

I am using the 28BYJ28 stepper with a geeetech stepper motor drive

Basically I am using this motor to rotate a large wheel at a constant speed of 1 RPH. in the meantime, the arduino board needs to take various readings and do tasks, but for simplicity purposes, let say it need to blink an LED without stopping the rotation of the motor. :roll_eyes:

obviously this code doesn’t work…

#include <Stepper.h>

Stepper mainwheel(200, 11,9,10,8);      

void setup() {
  // set the speed at 60 rpm:
   pinMode(13, OUTPUT);  

void loop() {

    digitalWrite(13, HIGH);   
  digitalWrite(13, LOW);    


Move the stepper in steps of 1 and use millis to decide when to do so. millis can also help you control the led. Or, look at the blink without delay example and add some stepper code to it.

Checkout the AccelStepper library.

Like MarkT suggested, the AccelSteppher.h library will help.

Look for these commands: stepper1.moveTo(4000);;

In the future, to help you find code that does this kind of thing (whether for steppers or otherwise), the term is "non-blocking"...

Thanks for the help but I’m still stuck…

here is the code I wrote.

#include <AccelStepper.h>

AccelStepper stepper1(4, 11, 9, 10, 8); 

void setup()

      pinMode(13, OUTPUT); 	


void loop()

      digitalWrite(13, HIGH);  
  digitalWrite(13, LOW);   

the LED blinks well but the motor nada…

Did you find any solution?

You have reactivated a 5 year old thread!!

MarkT: You have reactivated a 5 year old thread!!


i am activating 3 years old thread :)

i need a non blocking code/library for esp8266

See reply #2.