#include <Stepper.h>
int stepsPerRevolution = 12800; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper1(stepsPerRevolution, 2, 5);
Stepper myStepper2(stepsPerRevolution, 3, 6);
unsigned long currentMillis = 0; // stores the value of millis() in each iteration of loop()
unsigned long pastMillis1= 0;
unsigned long pastMillis2= 0;
int interval1 = 1;
int interval2 = 1;
void setup() {
// set the speed at 60 rpm:
myStepper1.setSpeed(120);
myStepper2.setSpeed(20);
Stepper1();
Stepper2();
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
currentMillis = millis(); // capture the latest value of millis()
// this is equivalent to noting the time from a clock
}
void Stepper1(){
if(currentMillis - pastMillis1 >= interval1){
myStepper1.step(stepsPerRevolution);
pastMillis1+=interval1;
}
}
void Stepper2(){
if(currentMillis - pastMillis2 >= interval2){
myStepper2.step(stepsPerRevolution);
pastMillis2+=interval2;
}
}
As of now the motors do not run with that code and I can't understand why. It seems that I set everything up.
I ran them earlier in parallel with this code
#include <Stepper.h>
int stepsPerRevolution = 12800; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper Stepper1(stepsPerRevolution, 2, 5, 3, 6);
//Stepper Stepper2(stepsPerRevolution, 3, 6);
void setup() {
// set the speed at 60 rpm:
Stepper1.setSpeed(120);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
("clockwise");
Stepper1.step(stepsPerRevolution);
}
But the issue is that I want to move them at different speeds and I can't seem to get that working for some reason. i followed the tutorial to the best of my ability but it seems I am missing something