#include <Stepper.h>
// Motor A
int ENA = 10;
int IN1 = 9;
int IN2 = 8;
int ENB = 5;
int IN3 = 7;
int IN4 = 6;
const int stepsPerRevolution = 180;
Stepper myStepper(stepsPerRevolution, IN1, IN2, IN3, IN4);
void setup ()
{
pinMode (ENA, OUTPUT);
pinMode (IN1, OUTPUT);
pinMode (IN2, OUTPUT);
pinMode (ENB, OUTPUT);
pinMode (IN3, OUTPUT);
pinMode (IN4, OUTPUT);
myStepper.setSpeed(60);
Serial.begin(115200);
}
void loop ()
{
static uint8_t enter = 1;
if (enter) {
enter = 0;
myStepper.step(stepsPerRevolution);
}
else {
myStepper.step(-stepsPerRevolution+20);
delay(500);
myStepper.step(stepsPerRevolution-20);
delay(500);
}
}