[Solved] Problem with 28BYJ-48 Stepper Motor

Hi everyone.

I have been having some trouble getting the 28BYJ-48 stepper motor working using the ULN2003 driver with my Arduino Uno board. Using either the stepper library or setting each pin to high voltage individually both result in the motor vibrating each time the motor tries to step, but the motor never actually moves. The LEDs on the driver also light up in the correct order which can clearly be seen at very low turn speeds. After trying to switch the order of the input pins, I think that the wires on the motor itself may be incorrect, as it seems like the order on the motor side is not the same as the order on the driver side (blue and pink, for instance, are reversed).

The motor is being powered by a separate 5V source from the Arduino and both the power source and the motor are attached to the ground pin on the arduino. The 4 input pins on the motor driver are wired to digital output pins 2-5 on the uno.

Here is the code from this tutorial to manually turn on each digital output pin one at a time:

int bluePin = 2;    //IN1 on the ULN2003 Board, BLUE end of the Blue/Yellow motor coil
int pinkPin = 3;    //IN2 on the ULN2003 Board, PINK end of the Pink/Orange motor coil
int yellowPin = 4;  //IN3 on the ULN2003 Board, YELLOW end of the Blue/Yellow motor coil
int orangePin = 5;  //IN4 on the ULN2003 Board, ORANGE end of the Pink/Orange motor coil

int currentStep = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);  
  
  pinMode(bluePin, OUTPUT);
  pinMode(pinkPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(orangePin,OUTPUT);
  
  digitalWrite(bluePin, LOW);
  digitalWrite(pinkPin, LOW);
  digitalWrite(yellowPin, LOW);
  digitalWrite(orangePin, LOW);
}

void loop() {
  
  Serial.print("Step: ");
  Serial.println(currentStep);
  
  switch(currentStep){
    case 0:
      digitalWrite(bluePin, HIGH);
      digitalWrite(pinkPin, LOW);
      digitalWrite(yellowPin, LOW);
      digitalWrite(orangePin, LOW);
      break;
    case 1:
      digitalWrite(bluePin, LOW);
      digitalWrite(pinkPin, HIGH);
      digitalWrite(yellowPin, LOW);
      digitalWrite(orangePin, LOW);
      break;
    case 2:
      digitalWrite(bluePin, LOW);
      digitalWrite(pinkPin, LOW);
      digitalWrite(yellowPin, HIGH);
      digitalWrite(orangePin, LOW);
      break;
    case 3:
      digitalWrite(bluePin, LOW);
      digitalWrite(pinkPin, LOW);
      digitalWrite(yellowPin, LOW);
      digitalWrite(orangePin, HIGH);
      break;
  }
  
  currentStep = (++currentStep < 4) ? currentStep : 0;
  
  //2000 microseconds, or 2 milliseconds seems to be 
  //about the shortest delay that is usable.  Anything
  //lower and the motor starts to freeze. 
  //delayMicroseconds(2250);
  delay(500);
}

Attached is an image of the motor connected to the driver. I would greatly appreciate any help in figuring out what is going on. Thanks.

Yes, the wiring is suspect. Other people have reported that the wire colors are not reliable. With the power off each time, swap pairs of motor leads and then reconnect the power to test, until it works properly.

Unfortunately with a 5-wire motor like this you have to use trial and error to work out the sequence,
you can't measure the windings on a multimeter as they are all the same.

With access to a 4 channel 'scope you can turn a 5-wire motor and look at the relative phases of the wires
simultaneously (though these little motors have so much gearing down you can necessarily turn them from
the output shaft).

There seems to be no consistency or standards for colour-coding motor wiring in my experience, as a given
motor is made with many options (shaft length, shaft end, encoder, voltage, bearing quality, etc etc), and
its infeasible to explain all the combinations on a datasheet. Each motor you come across is a new adventure!

Thanks for your help guys, I tried several combinations and switching two pairs of wires on the digital input pins makes the motor turn!

What wiring sequence worked for you?

crisnorwood:
What wiring sequence worked for you?

Crisnorwood, I don't think you are very likely to get an answer from the original poster - Icybit.

He asked his question 9 months ago, and then his only other post was later the same day to say his problem was solved.

You can hardly call him a regular poster.

For the benefit of others coming across this post, I had the same problem and found this.

The post didnt help but my strategy for solving involved checking the pins on the motor, despite the rest of the internet having correct schematice my PCB must be wired different, in particular the red is on the opposite side of the motor plug, the whole thing when correct is backwards, and the colours are not wired to int1 through int4 in the same way. So its process of elimination in the program to find the right solution.

Heres what did in code to allow me to test every solution....

// initialize the stepper library on pins 8 through 11:
//Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); // originally blue green yellow orange, now irrelevant
//Stepper myStepper(stepsPerRevolution, 8, 9, 11, 10);
//Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
//Stepper myStepper(stepsPerRevolution, 8, 10, 11, 9);
//Stepper myStepper(stepsPerRevolution, 8, 11, 10, 9); close right
//Stepper myStepper(stepsPerRevolution, 8, 11, 9, 10); cr
//Stepper myStepper(stepsPerRevolution, 11, 8, 9, 10); cr
//Stepper myStepper(stepsPerRevolution, 11, 8, 10, 9); cr
//Stepper myStepper(stepsPerRevolution, 11, 9, 8, 10);
//Stepper myStepper(stepsPerRevolution, 11, 9, 10, 8);
//Stepper myStepper(stepsPerRevolution, 11, 10, 9, 8);
//Stepper myStepper(stepsPerRevolution, 11, 10, 8, 9);
//Stepper myStepper(stepsPerRevolution, 9, 10, 11, 8);
//Stepper myStepper(stepsPerRevolution, 9, 10, 8, 11); cr
//Stepper myStepper(stepsPerRevolution, 9, 8, 10, 11);
//Stepper myStepper(stepsPerRevolution, 9, 8, 11, 10);
//Stepper myStepper(stepsPerRevolution, 9, 11, 8, 10); cl
Stepper myStepper(stepsPerRevolution, 9, 11, 10, 8); //strong
//Stepper myStepper(stepsPerRevolution, 10, 11, 8, 9);
//Stepper myStepper(stepsPerRevolution, 10, 11, 9, 8);
//Stepper myStepper(stepsPerRevolution, 10, 8, 11, 9); //strong
//Stepper myStepper(stepsPerRevolution, 10, 8, 9, 11); // backwards
//Stepper myStepper(stepsPerRevolution, 10, 9, 11, 8);
//Stepper myStepper(stepsPerRevolution, 10, 9, 8, 11);

I hope it helps others copy and paste a quick testing technique.

@thezerocool83

See what happens to code if you dont use the code tags.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum.