#include <AccelStepper.h>
// Define the motor interface type as DRIVER
#define MOTOR_INTERFACE_TYPE AccelStepper::DRIVER
// Create an instance of AccelStepper
AccelStepper stepper(AccelStepper::DRIVER, 3, 2); // Step pin: 3, Direction pin: 2
void setup() {
// Set the speed and acceleration (adjust these values as needed)
stepper.setMaxSpeed(1000); // steps per second
stepper.setAcceleration(500); // steps per second^2
// You can add any other setup code here
}
void loop() {
// Rotate the motor one full revolution clockwise
stepper.move(200); // 200 steps for one revolution (adjust if needed)
stepper.runToPosition();
// Add a small delay between rotations (optional)
delay(1000);
// Rotate the motor one full revolution counterclockwise
stepper.move(-200); // Negative value for counterclockwise rotation
stepper.runToPosition();
// Add a small delay between rotations (optional)
delay(1000);
}