Hi, Welcome to Robojax. My name is Ahmad Shamshiri and I am presenting this tutorial from Canada
in this video I'm going to show you how you can use
this stepper motor 27BYJ-48 with the ULN2003 motor driver module for Arduino.
Majority of the time people have issue with configuring this two together
and not be able to use it in this tutorial I'm going to show you the code
and also the code will be provided at robojax.com link will be at
the description below this video. This will be a very basic tutorial on showing you how
to rotate this and one direction and also in the other direction, I have created more
videos related to this motor. show you that to use some kind of
interrupts or other external factor or a sensor or something that makes the motor
rotate or change the direction or slow down or speed up but this is just basic
introduction of this motor how we can make it work or rotate with the whatever
direction we want so let's get start. I have a look at the specs for this model
this is the 5 volt type stepper motor. If you look this at the specs that is shown
on the on the diagram so here are the wires that you can see this is the pink
and we have pink orange red yellow blue. Here is
a red one. As you can see here the red is common between all of those so the red
is common and then each one represents a winding or a pole here so there are a
winding you see number of phases that it says it says 4 1 2 3 4 is the number of
phase. This is the chip and which I'm looking at the other specs here there
are many variations of ULN2003 or they all have a become with a dip 16
and or a so 16 so this is a surface mount version and this is a version that
we have here currently. And the difference is that you
in ULN2003 as 5 volt TTL and the ULN2002 works with 14 to 25 volts. And also these are all
variations. That is why we are connecting this to Arduino and Arduino's voltage
level is 5 volts so this works perfectly fine. Here the output they labeled advice
a 12 volts. This is connected here if you look at the aspects of the chip here this
chip has all of these inputs and then it depends on number of output that you use
on this board we have only up to 4 outputs. So 1 2 3 4 is used on the boards that is all
as you can see here they have no connection. Here so no pin so we have
only 4 input that we can use. We're using a four phase motor here that we are
controlling. What it does is there is a motors there is a diode for protection
freewheeling diodes as they call it and then we have an amplifier so the signal
comes here inverted and amplified. Now the inputs are here that we will
connect to the input 1 2 3 & 4 here and this these 2 goes go to motors so the
left side is more clearly here as negative (-) and the right side is marked as
positive (+). So this light will show status of each phase that will get signal.
here and here the all pins that we have, pin one two three and four
So four of those are corrected from blue and it goes on the
Arduino i've started so the one goes to number 10 and then
2 3 4 it goes to pin 10 11 12 the last one is common.
I'have connected it to the common. The circuit is powering up by arduino but
the motor does not. So Moodle needs external power it's very important the
circuit gets all the power from Arduino but the motor needs power, external power.
So you have to have some kind of battery or power adapter whatever that you have
to supply power. And based on the specification that I was looking this
motor shows that 5 volt DC so it will work with 5 volts. To connect your
battery, connect a positive here at the pin
the first one is negative the second one is positive. Here we have a spot here so
this is for the positive at the middle this is my positive and in order to make
this work when you're connecting your power adapter make sure that you connect
The negative to the Arduino board and the positive to the
motor or if you can split this and make it to piece that one negative goes to
the board and the other negative goes with the power that's also fine. Because
the negative is common between the board and Arduino I'm connecting the negative
here to the ground to the GND one of the poor that a phase GND. So this is
negative and here is my voltage source. I'm just plugging it in the negative
here. And here is the positive from my source. So now as you can see here the
positive is connected the negative from this point is also connected to my power
supply the motor is connected because Arduino doesn't have any power it
will not run but before I let me show you the code that I'm running and using
these are the pins on the chip who are referring to these pens that we have
here and then 10 11 12 13 refers to Arduino pins that we have here . The test
pin one should be to ten, two to eleven and three to twelve so so forth
this is determining the direction so for clockwise we say "false" and for
counterclockwise we say "true" which I'm going to demonstrate next. Then the setup()
port this is the main Arduino function it's
that pin one-two-three-four should be the output and then here the switch and
it says step step is this one initially when it is zero at the beginning it
sends pin one to load and to pin 3 and only pin for as high as you can see the
step when it become one also three and four is HIGHand then you will see that
that at the four is off and that three is HIGH slowly this goes 2 up and then
one you see here it's at the bottom and then 2 is HIGH and then one LOW and then
too HIGH it moves up and then one HIGH and then 2 HIGH at the top and then it
should come back to the bottom so one HIGH and then one HIGH at the top one
HIGH here and then LOW, LOW, LOW all of them. So that's it. After this it will be
repeated this is taking care of the direction after seven it just sets it to
zero the step will be 0 because in total with 7 because it starts with the zero
there is 8 because we have 4 phase 8 type of value will be enough to cover
this model and make it move. Connect the Arduino at the moment only blink is
blinking so this is pin number 13 which is which is just blinking here as you
can see. Let me upload the code into the board.
the motor as you can see is rotating now and as you can see this is
running clockwise. To change the direction of motor, we just say here
"true" and then upload this. Pay attention that this will first stop it can go
counterclockwise so this way the motor rotates
thank you very much the code for this tutorial is available the description by
clicking at it and at www. robojax.com Please "SUBSCRIBE so you get
updates for future videos and regards Arduino or any other electronic circuits
please subscribe so you can get updates take care
you