1

Before bothering anybody, I've been Googling this issue for the last three weeks and have not been able to solve the issue, so must reach out for help.

My son has done multiple Arduino projects after having a Creation Crate subscription, and now we're working on a project together. We bought a 28BYJ-48 stepper with driver, and figured it'd be just a question of copy-and-paste coding and we'd be in business.

I've tried the Arduino library, the AccelStepper library, countless other sketches from various websites and for some reason the stepper only vibrates when it's supposed to turn CCW. There was one sketch we were using that used Serial Monitor to enter in the number of steps, and when i'd do a minus number of steps, it'd go CCW, but the next day no longer would! I thought this was a motor or driver issue, but we've bought three more motor/drivers and still have the same problem. In researching an answer, I've seen some people say to switch IN 3 & 4 but I still get same results.

We've been connecting 8 to IN1, 9 to IN2, 10 to IN3 and 11 to IN4. Using a separate 5V power supply to the driver which is also grounded to the Arduino (have tried both ground pins just in case that makes a difference, but no). We've also tried changing for another Arduino and this hasn't made a difference either.

we've tried multiple sketches from multiple sources, here's one as an example:

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);

  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}

The Serial Monitor will state that it's turning CCW, but it isn't. Any help would be much appreciated! What we thought would be a simple step in our project has become a major roadblock!

  • which driver are you using? – jsotola Oct 21 '18 at 1:15
  • one of the problems lies here figured it'd be just a question of copy-and-paste coding ..... the only time you should be copy-pasting is when you truly understand the code that you are copying and you are 100% sure that there are no errors .............. maybe you can start by activating the stepper motor windings one after another using digitalWrite()with a 1 second pause between steps .... that should make the motor move between steps – jsotola Oct 21 '18 at 1:52
  • this appears to address your issue instructables.com/id/BYJ48-Stepper-Motor – jsotola Oct 21 '18 at 17:50
  • I'm using a ULN2003 driver board, thanks! – Matt Oct 23 '18 at 0:40
  • then look at the instructables.com page – jsotola Oct 23 '18 at 2:35
2

I had this issue myself, when I tried to use these stepper motors (which are to be honest really crappy ones, but very cheap). Vibrating mostly means, that the phases of the motor are not activated in the correct order. These motors seem to work with an activation pattern for half steps (I don't know, if the motor is really doing half steps with this, because I didn't counted them for a whole revolution. But at least they worked). The Stepper library (I assume from your code, that you are using this one) isn't meant for this driver, so it will turn on the phases in a wrong order and always two phases at the same time (as for full steps).

I had success, when driving the 4 phases of the driver with the following pattern (for half steps):

1000
1100
0100
0110
0010
0011
0001
1001

I also found hints on the web (on a german site, just for reference, if you can read german), that - despite being meant for half steps - you can drive the motor with full steps with the Stepper library as well. You would have to change the order of pins in the definition of the stepper:

Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

This assumes the wiring as: D8->IN1, D9->IN2, D10->IN3, D11->IN4. Note, that using full steps means 2048 steps per revolution.


I also found a library specific for this stepper motor, but I haven't tested it: Stepper_28BYJ_48


Now you can decide yourself, which way you want to go. I personally would go for the full steps with the official Arduino Stepper library.


About the number of steps per revolution: I don't know, why the stepper doesn't work with a vale of 2048. But since the library only uses this to wrap up the correct phases for the revolutions, you can use a lower value, that is dividable by 4. For example 32, which is the number of full steps per revolution of the actual motor (it is attached to gears with a factor of 64). That should work.

  • Thanks for the input- indeed changing the pin order to 8,10,9,11 did the trick. Oddly enough however, when I change variable for the steps per revolution from 200 to 2048 (the true number of steps in one revolution for this motor), it chokes and won't turn at all. 200 only turns it about a tenth of a rotation. I've played with this variable and can change it amp to 660 (about a quarter turn), but any number higher than this and the stepper won't turn at all. Any thoughts appreciated! – Matt Oct 21 '18 at 13:42
  • @Matt I edited by answer and added my thoughts about this. I hope, that helps. – chrisl Oct 21 '18 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.