A simple Arduino library for controlling stepper motors with DRV8825 / A4988 drivers.
- Supports DRV8825 / A4988 stepper drivers
- Easy control of speed & direction
- Enable/disable motor function
- Compatible with Arduino UNO, Mega, Nano
- Download the repository as
.zip
- Extract and move it to
Documents/Arduino/libraries/Stepper8825Lib
- In Arduino IDE:
Sketch -> Include Library -> Add .ZIP Library
pio lib install "Stepper8825Lib"
Basic example:
#include <Arduino.h>
#include "Stepper8825Lib.h"
#define STEP_PIN 2
#define DIR_PIN 3
#define ENABLE_PIN 4
StepperMotor motor(STEP_PIN, DIR_PIN, ENABLE_PIN);
void setup() {
motor.enable();
motor.setSpeed(500);
}
void loop() {
motor.setDirection(true);
motor.step(200);
delay(1000);
motor.setDirection(false);
motor.step(200);
delay(1000);
}
Creates a stepper motor instance.
Sets motor speed in µs per step.
Sets rotation direction (true
= CW, false
= CCW).
Moves the motor by a given number of steps.
Enables or disables the motor.
Licensed under the Apache 2.0 License. See LICENSE
for details.
Feel free to open issues or submit pull requests! If you like this project, consider starring the repo. 🚀