FYI - below is some Arduino code that demonstrates bidirectional operation of a 28BYJ-48 5-Volt stepper motor. It does not use the Arduino library partly because I wanted to get a bit more hands-on with the stepper to learn its operation and partly because the library isn't designed for this type of stepper and the pin assignments need to flipped around to work. Plus, I don't think that the library correctly addresses the eight codes required for this stepper and, instead, uses only four codes. Anyway, this code works well for a functionality demo. The code is based on some general stepper code that I found on the web (I don't recall where) and modified for the 28BYJ-48 stepper. I have also attached a photo of the stepper and interface board that I am using - <$5 for both on eBay. I have also attached a schematic for the ULN2003 Driver Board.

// This Arduino example demonstrates bidirectional operation of a // 28BYJ-48, which is readily available on eBay, using a ULN2003 // interface board to drive the stepper. The 28BYJ-48 motor is a 4-// phase, 8-beat motor, geared down by a factor of 68. One bipolar // winding is on motor pins 1 & 3 and the other on motor pins 2 & 4. // Refer to the manufacturer's documentation of Changzhou Fulling // Motor Co., Ltd., among others. The step angle is 5.625/64 and the // operating Frequency is 100pps. Current draw is 92mA. In this // example, the speed and direction of the stepper motor is determined // by adjusting a 1k-ohm potentiometer connected to Arduino pin A2. // When the potentiometer is rotated fully counterclockwise, the motor // will rotate at full counterclockwise speed. As the potentiometer is // rotated clockwise, the motor will continue to slow down until is // reaches its minimum speed at the the potentiometer's midpoint value . // Once the potentiometer crosses its midpoint, the motor will reverse // direction. As the potentiometer is rotated further clockwise, the speed // of the motor will increase until it reaches its full clockwise rotation // speed when the potentiometer has been rotated fully clockwise.////////////////////////////////////////////////

I've asked here in the motor forum. I have the same hardware. How do I make it go in reverse? I tried using step(-64) in the library, it only goes forward. Does this work for you? If not, should I use your code instead? If so, who not for me?

I do not personally know of a specific advantage other than this is how the manufacturer says that it should be done. It is intuitive that the manufacturer would not arbitrarily specify eight steps for no reason whatsoever. To turn the question around, do you anticipate some advantage for you to use the library function?

I was getting about 7RPM using 1,2,3,4 sequence in library.15RPM with decent torque using 1,3,2,4 in library.35RPM with your code and more torque!I can't even stop it with my finger.The improvement is like night and day.You have to increase the speed gradually during ~10ms to achieve 35RPM.Thanks!

The 8 step is called a half step, on alternate steps one winding is powered down. One note, you would be best to use bitmasks and port writes so that all motor field changes happen in unison whereas your code has them happening sequentially.

// This Arduino example demonstrates bidirectional operation of a // 28BYJ-48, which is readily available on eBay, using a ULN2003 // interface board to drive the stepper. The 28BYJ-48 motor is a 4-// phase, 8-beat motor, geared down by a factor of 64. One bipolar // winding is on motor pins 1 & 3 and the other on motor pins 2 & 4. // Refer to the manufacturer's documentation of Changzhou Fulling // Motor Co., Ltd., among others. The step angle is 5.625/64 and the // operating Frequency is 100pps. Current draw is 92mA.