28BYJ-48 5V 4 Phase DC Stepper Motor + ULN2003 Driver Board

Hey guys
Well, i’m new to Arduino, and really loving XOD, but it seams to lack lots of libraries.
I’m trying to setup a DC motor with shield, and there is no tutorial , help page or anything related as far as I can find.
This is the hardware: 28BYJ-48 5V 4 Phase DC Gear Stepper Motor + ULN2003 Driver Board
This is the tutorial I’m liking most (for Arduino IDE, just checking because of connections
I’m connecting the Driver to a 4x 1.5 AAA battery pack (external source) connected to the UNO GRD

How can I make a node to control this motor with shield?
Thank you

If you search the forum for “stepper”, there is this post giving basic steps for setting this up: Stepper Motor Driver and LED’s

Hum… Already saw that post, and ll it tells me is that there is no node yet, but the reply isn’t explicit on is anser and I still know the same.
I can make it work in Arduino IDE, but i’m finding XOD very lacking …

How do you do it in Arduino IDE? If it is just setting pins HIGH/LOW, and then pulsing the stepper pin, you can use the digital-write node to set and pulse the same pins. You will need a separate digital-write node for each pin that needs set/pulsed.

You will need something feeding the digital-write node for the stepper pin to provide the pulses. This could be a square-wave node, a flip-n-times node, or something more complicated if those don’t meet your need.

In Arduino I’m actualy using a library, since the default library doesn’t have much options for stepper motors

I’ll show the code of what a have so far (Make the stepper run with the push of a button)

Still medling with it…

#include <AccelStepper.h>
#define HALFSTEP 8

// Motor pin definitions
#define motorPin1  3     // IN1 on the ULN2003 driver 1
#define motorPin2  4     // IN2 on the ULN2003 driver 1
#define motorPin3  5     // IN3 on the ULN2003 driver 1
#define motorPin4  6     // IN4 on the ULN2003 driver 1

#define btn_1 12

// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

// Stepper Travel Variables
long TravelX;  // Used to store the X value entered in the Serial Monitor
int move_finished=1;  // Used to check if move is completed

void setup() {
  Serial.begin(9600);  // Start the Serial monitor with speed of 9600 Bauds
  pinMode(btn_1, INPUT_PULLUP);
  stepper1.setCurrentPosition(0);
  stepper1.setMaxSpeed(1000.0);
  stepper1.setSpeed(100);
  
  Serial.println("Stepper is Running . . . . . . . . . . . ");  
}//--(end setup )---



void loop() {

  //Change direction when the stepper reaches the target position
  //if (stepper1.distanceToGo() == 0) {
  //  stepper1.moveTo(-stepper1.currentPosition());
  //}
  
  if (!digitalRead(btn_1))  // Lê Pin 12 para botao
    {

      stepper1.runSpeed(); 
     // Serial.println(stepper1.currentPosition());
   }
}

I’ll try your way…
Just because I really liked XOD :stuck_out_tongue: can’t even understand why we still use C to program arduino, when a visual programming language like XOD can do it better and faster…

C/C++ will likely produce much smaller, faster-running code, but XOD is certainly easier to program with…assuming nodes for what you want to do exist. It is still better to use C++ inside XOD node for some things. As in this example, you can use lots of digital-write nodes to create a stepper node, or you could create a stepper node using C++ and the above header files and it would probably be more efficient and maybe easier to use. Unfortunately, at this point is is a cumbersome, manual process to add header files to your XOD install, but developers are working on a solution.

XOD is still in alpha state & 1st release was < 1 year ago. Developers are focusing on core functionality and hoping others will step up to create additional libraries to cover functionality like this so they have time to work on making XOD easier to use and extend.

3 Likes

Well, I’m still very green on Arduino… like got my first last week but I have experience with programming.
Tryed it in XOD and didn’t even get close
the Arduino IDE library also sucks… like, really bad to control steppers
Found AccelStepper Library and I’ts already running…
Actualy I don’t know what more to do, so, I’m moving to the next shield, but I would love If there were nodes for such shields and stuff…
Probably any programmer with some experience can do it in XOD, or even create a node. I would gladly share it If i knew how to do It.

Since I’ve got my solution for now, I’ll share it in the next Reply

For Arduino IDE
Hardware: 28BYJ-48 5V 4 Phase DC Stepper Motor + ULN2003 Driver Board
1 Button + resistor
https://www.aliexpress.com/item/Smart-Electronics-28BYJ-48-5V-4-Phase-DC-Gear-Stepper-Motor-ULN2003-Driver-Board-for-arduino/32706559510.html?spm=a2g0s.9042311.0.0.16784c4d6KcYm5
(Just bought two more… :stuck_out_tongue: )
Library: http://www.airspayce.com/mikem/arduino/AccelStepper/index.html

The speed values may be wrong, can’t find that information about this specific motor.

#include <AccelStepper.h>
#define HALFSTEP 8

// Motor pin definitions
#define motorPin1  3     // IN1 on the ULN2003 driver 1
#define motorPin2  4     // IN2 on the ULN2003 driver 1
#define motorPin3  5     // IN3 on the ULN2003 driver 1
#define motorPin4  6     // IN4 on the ULN2003 driver 1

#define btn_1 12
int pos = 0;

AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4); // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48

void setup() 
{
  Serial.begin(9600);  // Start the Serial monitor with speed of 9600 Bauds
  pinMode(btn_1, INPUT_PULLUP); // Set Button btn_1 as input
  stepper1.setCurrentPosition(0);
  stepper1.setMaxSpeed(5000.0);
  stepper1.setAcceleration(100.0);
  stepper1.setSpeed(10);
  
  Serial.println("Stepper is Running . . . . . . . . . . . ");
  delay(100); // Gives time for stuff to wake up 
}//--(end setup )---



void loop() 
{
  if (!digitalRead(btn_1))  // Lê Pin 12 para botao
    {
      pos++;
      stepper1.moveTo(pos);
      stepper1.run();
    }
}

Well, the post has been blocked (possible spam due to links), Admin will unblock it later.

I just pushed a lib that may help you: https://xod.io/libs/txgruppi/stepper-28byj48/

2 Likes