Well, no one answered my question about the customstepper library and it got to the 2nd page,
so ill try to open it in a new thread, if no one will answer ill probably should switch to the accelstepper library
I was experimenting with the customstepper library & 28BYJ motor, and trying to make the motor rotate one rev. in CW direction, then one rev. in CCW. the code looks somthing like below . the problem is the first "rotate" command is being ignored, the motor goes just 1 rev in CCW then stops.
i understand there are blocking/non-blocking commands, thats why i put the delay, but still its not working like i want.
will appreciate your help understanding why this happens and how make it to work.
thanks!
#include <CustomStepper.h>
int motorPin1 = 8; // Blue - 28BYJ48 pin 1
int motorPin2 = 9; // Pink - 28BYJ48 pin 2
int motorPin3 = 10; // Yellow - 28BYJ48 pin 3
int motorPin4 = 11; // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)
CustomStepper stepper(8, 9, 10,11, (byte[]){8, B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001}, 4076, 15, CW);
boolean rotate_end = false;
//////////////////////////////////////////////////////////////////////////////
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
//////////////////////////////////////////////////////////////////////////////
void loop()
{
if ( stepper.isDone() &&rotate_end == false)
{
stepper.setDirection(CW);
stepper.rotate(1);
delay(4000); //probably not needed ??
stepper.setDirection(CCW);
stepper.rotate(1);
rotate_end = true;
}
stepper.run();
}