Stepper couldn't run revert

I tested a stepper - 28BYJ-48(5vDC) in Arduino IDE 1.8.13 by Stepper library, I tried the example “stepper_oneRevolution”, while, I could only run in CW not CCW.

I have tried these ways:

  1. Alter pins from 4567 to 8-9-10-11 as the example used.
  2. change sequence 891011 to 810911.
    3.change the 2nd and 3rd lines on the driver board.
    4.change the code in “Stepper.cpp”
    from:
// AC-BC-BD-AD

      case 0:  // 1010

        digitalWrite(motor_pin_1, HIGH);

        digitalWrite(motor_pin_2, LOW);

        digitalWrite(motor_pin_3, HIGH);

        digitalWrite(motor_pin_4, LOW);

      break;

      case 1:  // 0110

        digitalWrite(motor_pin_1, LOW);

        digitalWrite(motor_pin_2, HIGH);

        digitalWrite(motor_pin_3, HIGH);

        digitalWrite(motor_pin_4, LOW);

      break;

      case 2:  //0101

        digitalWrite(motor_pin_1, LOW);

        digitalWrite(motor_pin_2, HIGH);

        digitalWrite(motor_pin_3, LOW);

        digitalWrite(motor_pin_4, HIGH);

      break;

      case 3:  //1001

        digitalWrite(motor_pin_1, HIGH);

        digitalWrite(motor_pin_2, LOW);

        digitalWrite(motor_pin_3, LOW);

        digitalWrite(motor_pin_4, HIGH);

      break;

to:

 // AB-BC-CD-DA

      case 0:  // 1010

        digitalWrite(motor_pin_1, HIGH);

        digitalWrite(motor_pin_2, LOW);

        digitalWrite(motor_pin_1, LOW);

        digitalWrite(motor_pin_2, HIGH);

      break;

      case 1:  // 0110

        digitalWrite(motor_pin_1, LOW);

        digitalWrite(motor_pin_2, HIGH);

        digitalWrite(motor_pin_3, HIGH);

        digitalWrite(motor_pin_4, LOW);

      break;

      case 2:  //0101

        digitalWrite(motor_pin_3, HIGH);

        digitalWrite(motor_pin_4, LOW);

        digitalWrite(motor_pin_3, LOW);

        digitalWrite(motor_pin_4, HIGH);

      break;

      case 3:  //1001

        digitalWrite(motor_pin_3, LOW);

        digitalWrite(motor_pin_4, HIGH);

        digitalWrite(motor_pin_1, HIGH);

        digitalWrite(motor_pin_2, LOW);

      break; 

neither of them worked, any suggestion?

Recheck your sequence, if that is not it post the schematic, not a frizzy as connected showing all interconnections.

I found an Arduino Library, it worked well - StepperControl, searched “28BYJ” in Arduino IDE → Tools → Manage Libraries…

By the project I made, I found this example code useful for Stepper shaft position alignment:

/*
 This a program for 28BYJ-48 Stepper's shaft alignment.
 It was used in such situation:
 You have fixed the Stepper in your project and operated it, while 
 there is a power-down unintended or a wrong operation, the Stepper's
 shaft stopped in an unintended position, and when power on again, it 
 runs from the new but unwanted origin.

 The program used in this way: 
 Download it into UNO board, and press the
 "RESET" button each time for 10 degree, or click the "Upload" button in
 Arduino IDE each for 10 degree.
 If the direction is reverted, comment the line with "::Backward", uncomment
 the line with "::Forward".

 Author:MQ
 E-mail:mian.qi@hotmail.com
 May.6, 2021 
 */

#include <StepperControl.h>

StepperControl control(StepperControl::DefaultStepCount, 4,5,6,7);

void setup() {
  // put your setup code here, to run once:
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);

  //control.SetDirection(StepperControl::Forward);
  control.SetDirection(StepperControl::Backward);
  control.SetRotationSpeed(2);
  control.SetStepType(StepperControl::FullStep);

  const uint32_t steps = control.GetStepsFromDegrees(10);
  control.Step(steps);
}

void loop() {
  ;
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.