#include <Stepper.h>
// Define constants for the stepper motor
// const int stepsPerRevolution = 2048;
const int stepsPerRevolution = 200;
//const int stepsPerDegree = stepsPerRevolution / 360;
// Define pins for the ULN2003 driver
const int in1Pin = 8;
const int in2Pin = 9;
const int in3Pin = 10;
const int in4Pin = 11;
// Define pin for the button
const int buttonPin = 2;
// Create a new instance of the Stepper class
Stepper motor(stepsPerRevolution, in1Pin, in2Pin, in3Pin, in4Pin);
void setup() {
Serial.begin(115200);
// Set the motor speed (RPM)
motor.setSpeed(50);
// Set the button pin as input
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// Wait for the button to be pressed
while (digitalRead(buttonPin) == HIGH) {
// Do nothing
}
Serial.println("Start Rotation");
// Rotate the motor 360 degrees (one revolution)
motor.step(stepsPerRevolution);
Serial.println("Stop Rotation");
}