Go Down

Topic: 28BYJ-48 5-Volt Stepper (Read 220084 times) previous topic - next topic


Nice simple code!  I have also included 4 non-blocking functions.


Off the top of my head while traveling I don't recognize ramp().
36000 is 360 degrees in my function call.
1200 is 12 RPM.

Ahh, reverse of what I thought - cheers, i'll keep playing!


Jun 28, 2013, 01:44 pm Last Edit: Jun 28, 2013, 02:38 pm by fcaldeira Reason: 1
2 Stepper motors with drive 28BYJ-48 (Chinese) + lib accellstepper

Hello everyone, I need help. I am wanting to use the lib that accellstepper

control over a stepper motor at the same time, but I can not for the code

using 2 motors running in opposite directions simutaneamente, triggered by buttons

for clockwise and counterclockwise. For lib "Stepper.h" and 2 engines already

get (below).

I thank anyone who can help.

Code: [Select]

#include <Stepper.h>

// 2 Motor de passo 5v + 2 botoes
#include <Stepper.h>  //Biblioteca já disponível na IDE do Arduino

#define STEPS 150  // max 100

const int steps=100;  //Número de passos para o motor
int buttonState1=0;
int buttonState2=0;
Stepper stepper1(STEPS, 0, 2, 1, 3); // Motor 1
Stepper stepper2(STEPS, 5, 7, 4, 6); // Motor 2

void setup()
stepper1.setSpeed(200);    //Velocidade da rotação do motor (RPM)
stepper2.setSpeed(200);    //Velocidade da rotação do motor (RPM)
pinMode(8,INPUT);   //Botão 1
pinMode(9,INPUT);   //Botão 2
pinMode(12,OUTPUT);   //LED


void loop()
if(buttonState1==LOW)   //Gira para um lado
else if(buttonState2==LOW)  //Gira para o outro lado
else   //Fica parado



Hi guys!

First of all thanks for the useful things in this thread.
The arduino is really new for me, so sorry about my noob questions.
I'd like to create a motorized camera slider, first only with one 28BYJ-48.
I found Sbright33's great library(https://gist.github.com/sbright33/4178431).
But I'm so confused about the wiring. Do I simply connect the 28BYJ-48 motor to the arduino board. In this case how can I get 12V? Eg from the arduino board's Vin pin?
Or do I need to use the ULN2003 board (Connect the 28BYJ-48 motor to the ULN2003 and the ULN2003 to the arduino board)?

Thanks for your answer.



Here's a good picture for you:

I made a camera slider too!  Thanks for the Compliments...


You can use 5V or 12V.  Some of my functions are designed for a 12V supply and 5V motor.


hey guy this working perfectly thanks a lot
can you make a knob version
(if you dont understant war the knob is):
control thr direction of the stepper thith a pontetiometer


I would consider it.  What do you mean exactly?

Can anyone think of any improvements to my code?  It's been awhile since I asked or made any changes.



I am trying to use the original code on the first page of this post. I have this same stepper, and I only need to rotate it once, 360 degrees. Nothing continuous, and not very often. When I use the CustomStepper library, it works very well. But when I try to use the code from the original post here, the motor is very slow, and that is when I have the speed dialed all the way up to "5". Plus if I feel the motor, it feels very stuttery, not smooth at all like when I use the CustomStepper library. I looked at that library, and it seems to do the same thing (uses digitalWrites to the pins, and in the same sequence). So what is the difference? What am I missing? And how can I optimize the original code to make it work the same way? I want to take that code, and then use shift registers to send the various HIGH/LOW commands to several stepper motors at once. Thanks!


Update. I just tried using a delay of "1", and that works very smoothly. Is there a way to use anything lower? Say "0.5"?


Update. I just tried using a delay of "1", and that works very smoothly. Is there a way to use anything lower? Say "0.5"?

I'm also new to this and just started to explore the different Demos. With the sketch from posting #1 it wont be possible to go faster than delay(1). But if you like, you can rewrite the sketch and use delayMicrosecond and recalculate the whole potmeter-reading.

BTW: I have a newer Version of the ULN2003 board. It is made in SMD fashion and features pins in1-7 and A-F.
This pcb must be powered in a different way, where GND and VCC are placed on a separate Header instead of using In5 for VCC.


...Can anyone think of any improvements to my code?  It's been awhile since I asked or made any changes.

I tried to understand what your code is doing. It seems, there are different voids to do the same Thing. " st07" is doing the 8-step thingy in an improved way, but there are also two others. Why?

There is a void "move" , which seems to be the simplest way to move the stepper.
It would help me a lot, if you could write a simple example program to demonstrate how to do microstepping or fast running.
Would you consider to split the sketch in a standard-(5v) and overclocked (12V)Version?

THX alot


Yes there are a few ways to step with st07.  Full steps and half steps.  4 or 8 of them.  Look for differences in the code.  You should not call these directly, as they are used by my functions.

move() is the easiest way to move one step.  The other functions use degrees and RPM as parameters.  Maybe you could help me by writing some demo code.  Just try one function call at a time in loop() or setup().  My Demo is only one short line of code.  They are commented out.  When you execute it you will see what it does.  Let me know if you have any questions about any of the function parameters.  I have written them up somewhere on github.  I can also translate what the function name means if you'd like.  The easiest way to learn is to try! 

Generally the "Cool" functions are designed for 12v.  There is no need to cool with 5v, as it will not be excessively hot to begin with.


Sep 14, 2013, 07:09 pm Last Edit: Sep 14, 2013, 07:31 pm by tone57 Reason: 1
Hey all, I just fell off the turnip truck and i just got one of these motors with the driver board.
don't have a clue how to wire it to my arduino. :~
Could one of you point me in the right direction while everyone else laughs and snickers?

Never mind i found it

i will have lots of other, hopefully better wuestions soon.


Go Up