Hello , so i made this programs (it work fine for few minute but i don't know if he will work for 24h ) and i assume there is much easier way to do it but i don't know at this time how ( it's my first Arduino code) , so if some one can help me to optimize it in any way i'd appreciate it because ir its seams realy primitive ( like save battery or make it more accurate or take less space in the Arduino).
/*
Stepper Motor Control - one revolution
*/
#include <Stepper.h>
const int stepsPerRevolution = 5; // 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, 3, 4, 5);
Stepper myStepper2(stepsPerRevolution, 10, 11, 12, 13);
void setup() {
// set the speed at 60 rpm:
myStepper1.setSpeed(10);
myStepper2.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("5");
delay (500);
myStepper1.step(stepsPerRevolution); // 00h05min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h10min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h15min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h20min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h25min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h30min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h35min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h40min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h45min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h50min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h55min
myStepper1.step(stepsPerRevolution); // 00h00min
myStepper2.step(stepsPerRevolution); // 01h00min
// 1H
delay (500);
myStepper1.step(stepsPerRevolution); // 00h05min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h10min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h15min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h20min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h25min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h30min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h35min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h40min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h45min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h50min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h55min
myStepper1.step(stepsPerRevolution); // 00h00min
myStepper2.step(stepsPerRevolution); // 01h00min
// 2H
delay (500);
myStepper1.step(stepsPerRevolution); // 00h05min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h10min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h15min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h20min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h25min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h30min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h35min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h40min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h45min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h50min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h55min
myStepper1.step(stepsPerRevolution); // 00h00min
myStepper2.step(stepsPerRevolution); // 01h00min
// 3H
delay (500);
myStepper1.step(stepsPerRevolution); // 00h05min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h10min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h15min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h20min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h25min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h30min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h35min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h40min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h45min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h50min
delay (500);
myStepper1.step(stepsPerRevolution); // 00h55min
myStepper1.step(stepsPerRevolution); // 00h00min
myStepper2.step(stepsPerRevolution); // 01h00min
// 4H
}
(only for 4h because the full program exceeds the maximum length but one block is 1h so normally there is 24 of them )
(delay is 500 ms but in real life it will be 300000 (5min))