// Stepper motor on Wokwi!
#include <Stepper.h>
const int analogPin = A0;
const int stepsPerRevolution = 200;
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 2, 3, 4, 5);
void setup() {
myStepper.setSpeed(60); // rpm
}
void loop()
{
// Read new position
int analogVal = analogRead(analogPin);
if (analogVal > 430) { // 2.1V
myStepper.step(stepsPerRevolution);
} else if (analogVal < 390) { // 1.9V
myStepper.step(-stepsPerRevolution);
}
}