// Stepper motor on Wokwi!
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper mec1(stepsPerRevolution,2,3,4,5);
Stepper mec2(stepsPerRevolution, 6,7,8,9);
void setup() {
// set the speed at 60 rpm:
mec1.setSpeed(60);
mec2.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
pinMode(1, INPUT);
pinMode(13, INPUT);
pinMode(12, INPUT);
pinMode(11, INPUT);
}
void loop() {
// step one revolution in one direction:
if (digitalRead(13) == HIGH) {
while (digitalRead(12) == LOW) {
mec2.step(1);
}
mec1.step(stepsPerRevolution/2);
}
}