28BYJ-48 5-Volt Stepper

I was able to get the Arduino stepper library to perform better for the 28BYJ-48, but, of course, the Arduino stepper library is limited and does not support acceleration/deceleration. Here is working Arduino stepper library code for the 28BYJ-48:

/*
  Derived from YourDuino.com Example Software Sketch
   Small Stepper Motor and Driver, by:
   terry@yourduino.com
*/

#include <Stepper.h>
//declare variables for the motor pins
int motorPin1 = 8;	// Blue   - 28BYJ48 pin 1
int motorPin2 = 9;	// Pink   - 28BYJ48 pin 2
int motorPin3 = 10;	// Yellow - 28BYJ48 pin 3
int motorPin4 = 11;	// Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)

#define STEPS  64   //Number of steps per revolution

//The pin connections need to be 4 pins connected
// to Motor Driver In1, In2, In3, In4  and then the pins entered
// here in the sequence 1-3-2-4 for proper sequencing of 28BYJ48
Stepper small_stepper(STEPS, motorPin1, motorPin3, motorPin2, motorPin4);

int  Steps2Take;

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  small_stepper.setSpeed(200);
}/*--(end setup )---*/

void loop()
{
  // sweep 1 turn each way
  small_stepper.setSpeed(200);   
  Steps2Take  =  2048;  // Rotate CW
  small_stepper.step(Steps2Take);
  delay(2000);
  
  small_stepper.setSpeed(200);  // 200 a good max speed??
  Steps2Take  =  -2048;  // Rotate CCW
  small_stepper.step(Steps2Take);
  delay(2000);

}

Most recently, I have been experimenting with the powerful accelstepper library (AccelStepper: AccelStepper library for Arduino). It supports acceleration/deceleration and much more. I posted a short demo video of a 28BYJ-48 being driven by the accelstepper library in full-step mode. It actually is more impressive in half-step mode but I didn't make a video of that. The video is at: accelstepper 28BYJ-48 demo - YouTube

The sketch used in the video is shown below:

// accellsteppertest.ino
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Derived from example code by Mike McCauley
// Set for 28BYJ-48 stepper

#include <AccelStepper.h>

#define FULLSTEP 4
#define HALFSTEP 8

//declare variables for the motor pins
int motorPin1 = 8;	// Blue   - 28BYJ48 pin 1
int motorPin2 = 9;	// Pink   - 28BYJ48 pin 2
int motorPin3 = 10;	// Yellow - 28BYJ48 pin 3
int motorPin4 = 11;	// Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)

// The sequence 1-3-2-4 required for proper sequencing of 28BYJ48
AccelStepper stepper2(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

void setup()
{    
  stepper2.setMaxSpeed(1000.0);
  stepper2.setAcceleration(50.0);
  stepper2.setSpeed(200);
  stepper2.moveTo(2048);
}

void loop()
{
  //Change direction at the limits
  if (stepper2.distanceToGo() == 0) {
    stepper2.moveTo(-stepper2.currentPosition());
  }
  stepper2.run();
}

The accelstepper library has many useful features. Check it out!