Using the 28BYJ-48 stepper motor, using stepper.h library in IDE 1.8.0 I can only get forward (CW) rotation. See photo attached. The sketch comes direct from Examples>Stepper>Stepper_oneRevolution, on pins 6,7,8,9 so no need to repeat it here.
Then I went to this forum and saw that other experimenters have had the same problem with CCW rotation. I don't understand if this is a unique problem to this stepper, or if other steppers exhibit similar issues. Seems like the basic code is simple, however the library does not provide proper control.
One of the threads suggested using AccelStepper.h, so I downloaded that along with this suggested sketch. Although I see nothing suggesting CCW operation.
#include <AccelStepper.h>
// Define some steppers and the pins they will use
AccelStepper stepper1(5, 6, 7, 8, 9);
// The first argument '5' indicates that we're using a 28byj-48 geared motor. The rest is just pin numbers.
//You can still use all the other types of motors supported by accelstepper library (e.g. 4 for a normal 4 wire step motor, 8 for a halfstepped normal 4 wire motor etc.)
AccelStepper stepper2(5, 6, 7, 8, 9);
void setup() {
stepper1.setMaxSpeed(900.0); //max speed of the first motor - modify if you want to
stepper1.setAcceleration(700.0); // rate at which the first motor accelerate -
stepper2.setMaxSpeed(700.0);
stepper2.setAcceleration(400.0);
}
void loop() {
if (stepper1.distanceToGo() == 0){
stepper1.moveTo(random(1500,7000));//just an easy way to get the motors to move to random positions
}
if (stepper2.distanceToGo() == 0){
stepper2.moveTo(random(1500,7000));
}
stepper1.run();
stepper2.run();
}
No stepper movement at all. I've tried changing the speed and acceleration with no effect. So, now I am at a loss of what to try next. It doesn't seem that this should be difficult. Does anyone have an easy, surefire fix? Thanks in advance.