Go Down

Topic: new Arduino library: CheapStepper - made for the cheap 28BYJ-48 stepper motor (Read 690 times) previous topic - next topic


I created a new library for the 28BYJ-48 Stepper motor (with ULN2003 driver board) and wanted to share it with you all:

https://github.com/tyhenry/CheapStepper  (It's also available on the Arduino Library Manager)

The 28BYJ-48 stepper motor is readily available and very inexpensive - yet quite decent for the money.

The library uses 8-phase half-stepping to give 4096 discrete (mini-)steps per shaft rotation for precise control.

The total steps per rotation is also adjustable :

  • the motor has an advertised 64:1 gear ratio but it has been measured as being 63.68395:1, which would give ~4076 steps per shaft rotation. 
  • you can also adjust this value to account for external gear ratios
    (e.g. if you are controlling a turntable with 1:4 motor:turntable gearing, change total steps to [4096*4=] 16384 steps, and then your motor control - rpm, degrees, etc. - will match your turntable)

The library allows you to:
control the stepping directly (CheapStepper::step()) or

use blocking moves (CheapStepper:move()) - i.e. sketch will "pause" - or

use non-blocking moves (CheapStepper::newMove() and CheapStepper:run()) - i.e. moves will be timed to occur across loop() iterations

More info is available on the GitHub repo and in the library code (fully commented!)

This is my first Arduino library, so I'm happy to receive feedback or pull requests!

- adjustable voltage input (right now calcs are based on 5v)
- acceleration/de-accelaration
- easier external gear ratio adjustment

I'm using this library right now to build a 3D scanner and it's working quite well :)


Although, now that I'm playing with it, I can't seem to declare the stepper on other pins. Is there something inherent in the library that forces the use of pins 8, 9, 10, and 11?



This is my first Arduino library, so I'm happy to receive feedback
Your constructor is setting the mode of the pins before the hardware is ready. Not a good idea.

Your class needs a begin() method, where the pinMode() calls should be made. The begin() method should be called in setup().
The art of getting good answers lies in asking good questions.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131