5V Stepper Motor 28BYJ-48 issue - Vibrating without rotation

Hey Guys! I am new to the Particle community and to the world of SOCs in general.

I am currently having an issue with getting a 5V Stepper motor you might be familiar with: 28BYJ-48.
I did read the forums similar to this topic, but could not find a satisfactory solution.

I am currently running a simple ‘brute force’ code to switch on the relevant pins in an order with a 0.5sec time delay in between them.

From the online forums and discussions, it seems this is an issue with the firing order but I cant seem to recognise the fault, nor can I pinpoint if its some other issue.

I apologise if this is issue is a trivial one and already solved with a motor shield etc…I am very keen to get it right with first principles before moving on to shields etc.

Some simple measurements made:

  1. Voltage between VIN and GND of the Photon holds good at 4.95V
  2. Current from L293D output pin to GND (without any motor/resistor attached) read 1.3 A on the mutimeter

I have provided all the details below

PROBLEM :
The Motor is simply vibrating in at the same frequency as the step interval, but not turning.

HARDWARE USED:

  • Photon
  • Stepper Motor 5V 4phase 28BYL-48 5-WIRE
  • Battery: 9V Duracell 170mAh (for testing only)
  • Driver: L293D
  • Voltage regulator - 7805
  • 10 microfarad caps for bypass

SETUP BELOW:

FIRING ORDER USED:

Note: The RED supply (5th wire ) is unused.


CODE:

//-----------------------------------------------------------------------------
// INPUTS/OUTPUT pins

//GPIO OUTPUTS
int LEAD1_BLUE = D1; // GPIO OUTPUT FOR MOTOR LEAD 1 (COIL2 END2)
int LEAD2_PINK = D2; // GPIO OUTPUT FOR MOTOR LEAD 2 (COIL1 END1)
int LEAD3_YELLOW= D3; // GPIO OUTPUT FOR MOTOR LEAD 3 (COIL2 END1)
int LEAD4_ORANGE= D4; // GPIO OUTPUT FOR MOTOR LEAD 4 (COIL1 END2)

//------------------------------------------------------------------------------

void setup() {
  // Put initialization like pinMode and begin functions here.
  //Initialize the OUPUT pins
  pinMode(LEAD1_BLUE, OUTPUT);
  pinMode(LEAD2_PINK, OUTPUT);
  pinMode(LEAD3_YELLOW, OUTPUT);
  pinMode(LEAD4_ORANGE, OUTPUT);
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
  //------------------TESTING ONLY----------------------------------------
  digitalWrite(LEAD1_BLUE, HIGH);
  digitalWrite(LEAD2_PINK, HIGH);
  digitalWrite(LEAD3_YELLOW, LOW);
  digitalWrite(LEAD4_ORANGE, LOW);
  delay(500);
  digitalWrite(LEAD1_BLUE, LOW);
  digitalWrite(LEAD2_PINK, HIGH);
  digitalWrite(LEAD3_YELLOW,HIGH);
  digitalWrite(LEAD4_ORANGE, LOW);
  delay(500);
  digitalWrite(LEAD1_BLUE, LOW);
  digitalWrite(LEAD2_PINK, LOW);
  digitalWrite(LEAD3_YELLOW,HIGH);
  digitalWrite(LEAD4_ORANGE,HIGH);
  delay(500);
  digitalWrite(LEAD1_BLUE, HIGH);
  digitalWrite(LEAD2_PINK, LOW);
  digitalWrite(LEAD3_YELLOW, LOW);
  digitalWrite(LEAD4_ORANGE, HIGH);
  delay(500);
}

Try this. Use pin 5 by tying it to the same source as what your calling logic 1.

 (1)   (2)   (3)    (4)    (5)

  1     0     1      1      1
  1     1     1      0      1
  1     1     0      1      1
  0     1     1      1      1

Basically, you want to energize coil 2, then 4, then 3, then 1, and repeat.

Hey mikemoy,

Thanks a lot for your response! Really appreciate…

I did try this strategy, but it does not seem to be working:(

I am trying to understand the sequence from the Arduino website and work out from there…
Its a bit startling that this little motor does not seem to have a clear datasheet showing the coil firing sequence/schematic or at-least none I could find!

I am now double checking the current etc, although I doubt this is the issue…

Thanks a lot though…Ill post something if I find a solution…


int A = 2;
int B = 3;
int C = 4;
int D = 5;
long del = 2000;
int step = 1;

void setup() {                
  pinMode(A, OUTPUT);     
  pinMode(B, OUTPUT);     
  pinMode(C, OUTPUT);     
  pinMode(D, OUTPUT);     
}

void one(){
  digitalWrite(A, LOW);   
  digitalWrite(B, HIGH);   
  digitalWrite(C, HIGH);   
  digitalWrite(D, LOW);   
  delayMicroseconds(del);
}
void two(){
  digitalWrite(A, LOW);   
  digitalWrite(B, HIGH);   
  digitalWrite(C, LOW);   
  digitalWrite(D, HIGH);   
  delayMicroseconds(del);
}
void three(){
  digitalWrite(A, HIGH);   
  digitalWrite(B, LOW);   
  digitalWrite(C, LOW);   
  digitalWrite(D, HIGH);   
  delayMicroseconds(del);
}
void four(){
  digitalWrite(A, HIGH);   
  digitalWrite(B, LOW);   
  digitalWrite(C, HIGH);   
  digitalWrite(D, LOW);   
  delayMicroseconds(del);
}
void motorOff(){
  digitalWrite(A, LOW);   
  digitalWrite(B, LOW);   
  digitalWrite(C, LOW);   
  digitalWrite(D, LOW);   
}

// the loop routine runs over and over again forever:
void loop() {

  for (int i=0; i<=500; i++){
    one(); 
    two();
    three();
   four();
  }
  motorOff();
  
  delay(2000);
 
}

i tried your code on my arduino it did not work try this code just change pin numbers to your photon
your are running this as a biopolar stepper .