#include <AccelStepper.h>
AccelStepper stepper1(1, 3, 2); // (Typeof driver: with 2 pins, STEP, DIR)
void setup() {
stepper1.setMaxSpeed(100); // Set maximum speed value for the stepper
stepper1.setAcceleration(500); // Set acceleration value for the stepper
stepper1.setCurrentPosition(0); // Set the current position to 0 steps
}
void loop() {
for(int i = 0;i<3 ; i++){// No of wiper wipes per process
stepper1.moveTo(50); // Set desired move: 50 steps for 90 degree
stepper1.runToPosition(); // Moves the motor to target position w/ acceleration/ deceleration and it blocks until is in position
// Move back to position 0, using run()
stepper1.moveTo(0);
while (stepper1.currentPosition() != 0 ) {
stepper1.run(); // Move or step the motor implementing accelerations and decelerations to achieve the target position. Non-blocking function
}
}
delay(10000); // Adda a Delay between each wiper wipe for our project Purpose
}