// Stepper motor on Wokwi!
#include <Stepper.h>
const int stepsForMin = 25; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper1(stepsForMin, 4, 5, 6, 7);
// initialize the stepper library on pins 8 through 11:
Stepper myStepper2(stepsForMin, 8, 9, 10, 11);
void setup() {
// set the speed at 100 rpm:
myStepper1.setSpeed(100);
myStepper2.setSpeed(100);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
for(int i = 0; i < 6 ; i++)
{
// 0-9 part of the min hand
for (int j = 0; j < 10; j++)
{
Serial.print("Min hand at: ");
Serial.print(i);
Serial.println(j);
myStepper2.step(stepsForMin);
delay(100);
}
// Moving the 0-9 part back to zero
Serial.println("Min hand setting back to 0");
myStepper2.step(-stepsForMin * 10);
Serial.println("Min hand set back to 0");
// 1-5 hand
myStepper1.step(stepsForMin);
Serial.println("Min hand set back to 0");
}
}