Arduino library and Fritzing parts for the X113647 stepper board
MIT License
The 28BYJ-48 stepper motor and ULN2003A-based X113647 Stepper Motor Driver Board is pretty common in Arduino kits, and available from various suppliers on aliexpress.
I've gone into more detail, including Fritzing parts, in the LittleArduinoProjects repository:
Although the name is now a bit misleading, this project started as an attempt to address two issues:
I've updated the X113647Stepper library to better reflect these issues. Feel free to borrow and use this library if it helps. In general though, I'd recommend alternatives:
Most (all?) versions of the 28BYJ-48 expose a consistent Blue-Pink-Yellow-Orange-Red wire sequence at the connector. Red is the common (5V/positive) connection.
The full step sequence required by the 28BYJ-48 for the 4 control lines is:
Step | Blue | Pink | Yellow | Orange |
---|---|---|---|---|
1 | 1 | 1 | ||
2 | 1 | 1 | ||
3 | 1 | 1 | ||
4 | 1 | 1 |
The standard Stepper Library implements the following sequence:
Step | C0 | C1 | C2 | C3 |
---|---|---|---|---|
1 | 1 | 0 | 1 | 0 |
2 | 0 | 1 | 1 | 0 |
3 | 0 | 1 | 0 | 1 |
4 | 1 | 0 | 0 | 1 |
It is readily observed that switching Pink/Yellow (C1/C2) aligns things nicely, so we end up with a 1-3-2-4 pin mapping for initializing the standard Stepper library as follows:
Stepper myStepper(STEPS_PER_REVOLUTION, PIN_IN1_BLUE, PIN_IN3_YELLOW, PIN_IN2_PINK, PIN_IN4_ORANGE);
In full-step mode, STEPS_PER_REVOLUTION
is 32 (steps) * 64 (gear reduction) i.e. 2048.
The X113647Stepper
class (in the tardate
namespace) is virtually a drop-in replacement for the Stepper library.
Basic initialisation (full step mode by default):
tardate::X113647Stepper myStepper(STEPS_PER_REVOLUTION, PIN_IN1_BLUE, PIN_IN2_PINK, PIN_IN3_YELLOW, PIN_IN4_ORANGE);
Or add the StepMode parameter. For example, half-step:
tardate::X113647Stepper myStepper(STEPS_PER_REVOLUTION, PIN_IN1_BLUE, PIN_IN2_PINK, PIN_IN3_YELLOW, PIN_IN4_ORANGE, tardate::StepMode::HalfStep);
Example sketches:
The stepper motor and driver will typically draw at least 130mA at 5V with HalfStepSweep, and over 250mA at 5V with WithStepperLibrary, so it is not particularly advisable to power directly from the Arduino's regulated supply.
Note the crossover of the wires eminating from the 28BYJ-48. This is actually done in the wiring of the standard connector provided with the stepper motor - but I haven't included this detail in the part as yet.