Whether we care to admit it or not, motors can be found all over in our everyday lives; they just tend to be hidden. Motors are present in cars, printers, computers, washing machines, electric razors, and much more.

However, there are a number of people (which until recently included myself) that would be uncertain of how to make a motor run if they were handed one. So, let's learn something today. Let's learn how to use a stepper motor!

Step 1: Materials That I'm Using

In order to demonstrate how to use the stepper motor (a hybrid stepper motor), there are a few things that I will end up using.

Both the stepper motor and the Darlington Transistor Array are available in the chipKIT Starter Kit.

<p>So I am using a 4 wire but it just hums, the shaft does not move. I am confused.</p>
Generally, when I encountered the humming it meant that the various poles on the motor are not being enabled/disabled in a sequential order or that you are not using a high enough voltage to get the motor to turn. I had a bit of trouble getting the 5V motor I used to nicely rotate with 3.3V logic.
<strong>This is really cool!!!!</strong>
<p>I made this example with an Arduino Nano changing the pin numbers because it has no pin higher than #13.</p><p>Another change I made is that I simply used a driver board instead of the raw Array-CI. This is more practical but has no electronic difference.</p><p>The good part of this example is that no library is required.</p>
<p>Very nice Instructable. Thanks</p><p>The very best</p>
<p>Help Is that woking for Arduino Mega 2560 +Ramp 1.4</p>
<p>it is very helpful to understand the stepper motor thank you</p>
<p>I've been having some trouble with motors. I'm completely new to this and I've been playing about with all sorts of arduino sketches from here and their example ones, but all of the motors feel like they're burning rubber on the inside without actually moving the shaft. I've tried dcs, servos and steppers, so I assume it's something I'm doing, but I can't work it out. Has any got any ideas? Any and every is welcome at this stage!</p>
<p>When you opened with &quot;Whether we care to admit it or not, motors can be found all over in our everyday lives&quot; I just imagined someone denying that motors make our phones vibrate and our garage doors open and how hilarious that would be....</p>
<p>It would be pretty funny, although admittedly I was one of those people (admittedly awhile ago) that was living in those dark ages thinking that motors were everywhere. I'm not sure how I would've answered onto how a phone vibrated though; that's probably part of the reason of why I am now correctly informed.</p>
<p>12v stepper motor control with a arduino</p>
<p>Nice instructable. I wanted to test and see if I can run several steppers I've been collecting, but I noticed the ULN2803A only stands 500mA per collector. And the stepper motor I have runs at 0.7 amps. I was wondering if you know another popular array (with 4 transistors if necessary) that can handle around 1 amp. </p><p>I guess I could also buy transistors per separate, but I prefer a less bulky chip.</p><p>Thanks for your time.</p>
<p>You can double the capacity to handle current by combining 2 inputs and 2 outputs. If you want to upgrade an existing project, simply solder another 2803 on top of the first chip.</p>
<p>To be honest, I haven't worked much with transistors until this Instructable, so I do not know what a &quot;popular&quot; one might be. </p><p>However, after doing a search on digikey, I did find a <a rel="nofollow">list of transistor arrays</a> that had outputs of 1amp or greater. There are a bunch of individual transistors that will also work (since it's easier to get a big heat sink on them), but as you said, they are more bulkly.</p><p>Let me know if you have any more questions.</p>
<p>Thanks, I did a bit of research too and I bought a L293DNE and I plan to buy a L298, I still don't know too much about the L298 and H bridges, but I'll get into it eventually. Thanks!</p>
<p>Sounds like fun! I haven't gotten much opportunity to work with H-Bridges myself, but they don't look too bad; they're essentially a set of switches that let you complete the circuit in one direction or the other. At least, that's what I learned from this Learn Module: <a href="http://learn.digilentinc.com/Documents/325" rel="nofollow">http://learn.digilentinc.com/Documents/325</a><br></p>
<p>Thanks for the info! I successfully drove a stepper motor I found in a printer, although the voltage has a strong correlation speed of the motor, causing it to fail if it's not set up according to the stepping speed. I guess this could be solved with a current limiter. I'll keep trying.</p>
<p>You could use a current limiter to get that rotation speed slower. I'm not sure how the printer stepper motor is set up, but if it has a bunch of individual steps like mine, you could just increase the delay time between energizing the individual coils, effectively making it rotate slower.</p>
<p>Apparently, my link below doesn't work (at least for me) so here is the expanded link: <a href="http://www.digikey.com/product-search/en?pv812=183&pv812=191&pv812=426&pv812=238&pv812=216&pv812=186&pv812=178&pv812=188&pv812=173&pv812=108&pv812=177&pv812=46&FV=fff40015%2Cfff8007a&k=darlington+transistor+array&mnonly=0&newproducts=0&ColumnSort=0&page=1&quantity=0&ptm=0&fid=0&pageSize=25" rel="nofollow"> http://www.digikey.com/product-search/en?pv812=18...</a><br></p>
<p>i want to activate my nema 17 stepper motor just only in 45 degrees angle. how can i do it? please help. thank you. :D</p>
<p>Good article Colvin. If you were to use a stepper motor as a generator which would be better a unipolar or bipolar ? Is there any special requirements to produce good results. I was thinking of a simple kids project.</p>
<p>i really need help fast</p>
<p>my adriuno said there was no coil4 pls help me</p>
<p>You forgot to mention the big advantage of unipolar motors; the whole reason they exist: you only need 4 transistors to drive a unipolar motor; you need 8 (2 full bridges) to drive a bipolar motor. So if you don't need the full strength of a bipolar motor, the unipolar motor is much simpler and easier to drive (so simple you don't even need a stepper motor driver or board, just literally four transistors wired straight to your microcontroller).</p>
You're completely right; the fact that the unipolar stepper motor just flat out requires less components to operate makes it much more accessible and convenient to use for a wider variety of people.
<p>thank u very much that was helpful :)</p>
<p>Hii I would like to know from you that I am trying to make a system where the stepper motor needs to to give a step of 8 degree every 30 minutes. </p><p>Stepper motor model - BH42SH33-0404A</p><p>I need to know the required arrangements and driver circuit required for the system to work.</p><p>I will be grateful if you can help me out in this problem. Nayone if you can, please help.</p>
<p>USE L297+L298 </p>
<p>Please help me!!! I have used this technique to drive my unipolar stepper motor just a little bit another way and succeeded to run in CCW that means first loop works fine but at second loop my stepper just vibrate and do not run CW after that it runs again CCW mode. <strong>The motor heated up a lot afer few cycle. </strong> whats wrong with my code? I am using 24BYJ48 motor, Atmega8, ULN2003 and codevision avr.</p><p>PORTB=0b00001001; // setting the inital state of the electromagnets</p><p>delay_ms(20);</p><p>while (1)</p><p>{</p><p>for(i=0; i&lt;202; i++) // looping through this chunk of code for ~ a full rotation</p><p>{ //This loop works</p><p>PORTB=0b00001001; delay_ms(20);</p><p>PORTB=0b00001100; delay_ms(20);</p><p>PORTB=0b00000110; delay_ms(20);</p><p>PORTB=0b00000011; delay_ms(20);</p><p>}</p><p>PORTB=0b00000110;</p><p>delay_ms(2000);</p><p>for(i=0; i&lt;202; i++)</p><p>{ //This loop not working</p><p>PORTB=0b00001100; delay_ms(20);</p><p>PORTB=0b00001001; delay_ms(20);</p><p>PORTB=0b00000011; delay_ms(20);</p><p>PORTB=0b00000110; delay_ms(20);</p><p>}</p><p>PORTB=0b00000110;</p><p>delay_ms(2000);</p><p>};</p><p>}</p>
<p>Great ible! thanks for sharing! I was wondering if it is possible to controll more than 2 steppers with an arduino board? something like 10 or 20 of them (why not 100). Did anyone try something like this? </p>
<p>In theory, the answer is yes.</p><p>However, you will be limited by how many output pins your board has since most stepper motors need 4 signals lines. So, since Digilent's uC32 has 42 input/output pins, I could theoretically drive up to 10 of them. This could be expanded even further by using a <a href="https://www.instructables.com/id/Operating-a-Shift-Register/" rel="nofollow">shift register</a> in combination with the Darlington Array.</p><p>But, you will be limited in terms of how much current your microcontroller can output, so you would need to use a power supply as your source of current. If you are driving a lot a steppers though, eventually you will become limited in how quickly you can have your microcontroller switch which electromagnets are &quot;turned on&quot; in your plethora of steppers.</p><p>In short, you can definitely drive two stepper motors with an arduino. More steppers will require more work.</p><p>Let me know if you have any other questions!</p>
Thank you! I'll give it a try with Digilent's chipKIT Max32, with more than 80 I/O ! and the easy stepper driver. This one only requires 2 outputs per stepper, if I am not wrong!<br><br>=40 steppers on 1 board!<br><br>Thank you once again for helping!
<p>Actually, the chipKIT Max32 will still need to have 4 outputs per stepper (since stepper motors need 4 inputs). So, you'll only be able to wire up 20 steppers to the Max32, but, nevertheless, that's still quite a lot.</p><p>Good luck!</p>
<p>Well if I'm not wrong, the easy driver can control a stepper by only using 2 digital outputs, <a href="https://www.sparkfun.com/products/10267" rel="nofollow">https://www.sparkfun.com/products/10267 </a> . You can find cheap copy of these ones for less than 2$</p><p>I ordered a few of them to run some tests....</p><p>my goal: <a href="http://2.bp.blogspot.com/_9cvLDPPuQJw/S6u2hNwojMI/AAAAAAAAGQY/DVFst9A6OF8/s640/Kinetic_Sculpture_BMW_Museum.jpg" rel="nofollow">http://2.bp.blogspot.com/_9cvLDPPuQJw/S6u2hNwojMI/...</a></p><p>Thanks once again</p>
<p>Oh ok, that's pretty cool!</p>
<p>Hello, I tried to drive the motor 24BYJ48A using a PmodStep (the driver). I used a function generator to provide the PWM ignal and I used 5V for at the pin 1 of J1 and sent the signal on pin 5. I connected the jumper JP1 to Vcc and i also connected an external power supply (5V) at H5 taking the right pin to be negative and left pin to be positive (5V ). I then connected the motor to J2 (bipolar), connecting orange wire to pin 1, yellow to pin 2, pink to pin 3 and blue to pin 4. Still my motor only vibrates but does not rotate :/ Can anyone help??</p>
<p>Hi sweta.dauhawoo,</p><p>You will need to send separate pwm signals for each of the wires (orange, yellow, pink, and blue), corresponding to signals 5, 6, 7, and 8, respectively, which are pins 7, 8, 9 and 10 on the 6x2 pin header. Also, you will not need to use both Vcc and an external power supply; only one of those is needed to run the stepper motor.</p><p>The PmodSTEP is not actually a driver in the traditional sense. It is simply a &quot;pass-through&quot; board that physically organizes your signals.</p><p>If you are wanting to run the stepper motor in bipolar mode, you will need to be able to produce a negative voltage (or have current run in the opposite direction through the coils). This can be accomplished by having your system board interface with an H-Bridge before the signals reach the stepper motor.</p>
Is it possible to ignore the common wire (red in this motor) of 28BYJ48A s (the one in this instructable ) and use it as 4 wire bipolar ? Because some motors are different and it isn't possible to do this with them , but I don't know about 28BYJ48As .
<p>It can be done but it's not that easy. I 've done it in my projects (you can check them on Instructables! ) and it surely doubles the torque. It can't be done directly because a bipolar motor has no &quot;common&quot; wire tapping both coils (this is what red wire is doing). </p>
<p>Not really that difficult... currently you are using 5 lines... four for coils, and one where the two ground lines are tied together. If you ignore the grounds... you can drive the coils directly... lines 1-2 for one coil, and 3-4 for the other. You are currently using 4 signal lines... connect up a SN754410NE chip, and use your four signal lines to drive that... The chip will create the +/- signals needed... although your bit pattern will be different. And you get the extra torque. I am using 6-line steppers on my lathe... and one day thought about that... I rewired them and now they run cooler with more torque.</p><p>Let me do a quick Google search... ah... found some examples... here is one...</p><p><a href="http://roevalley.com/newsbrowser/pi_projects/pi_bi-step.htm" rel="nofollow">http://roevalley.com/newsbrowser/pi_projects/pi_bi-step.htm</a></p><p>Someone want to do an Instructable on this?</p><p>Huh... just found 10 of them in my drawer... let me see if I have time...<br></p>
<p>6-wire motors can work like this but 5-wire ones can't (tried it myself). To make 5-wire motors bipolar you have to destroy the common wire connecting the 2 coils (open the motor). This isn't difficult using the 28byj-48 motors, there is even a youtube video about it.</p>
<p>I'll have to try it... in theory... if you put +V on one side of the coil, and -V on the other side, the center tap should be 0V. I would think that it would not effect the other coil... if there are slight manufacturing differences... you would get some minor inefficiency... but overall should still be better. I'll wire one up and do some testing. I don't want to modify the stepper... so that I can revert if I want to. If I get the chance to test it out, I'll update here.</p>
<p>You can use an H-bridge with a 5-wire motor but you need to ground the common wire. If you don't you will get jogging and nothing else.</p>
<p>Totally! </p><p>From my understanding and the research that I've done, the nearly all stepper motors can be run as a bipolar stepper motor as long as you leave the common wire floating. I just didn't have a way to create a negative voltage (or have a convenient H-bridge on hand to reverse the current) so I ran this motor as a unipolar stepper motor.</p><p>As a side note, the stepper motor I used, at least according to the sticker on the back of it, is actually 24BYJ48A. That being said, I don't think there is a difference between it and the 28BYJ48A, so both of those motors can be run as either a bipolar or unipolar stepper motor.</p>
<p>Look at the L293D chip or the <a href="http://www.mouser.com/ProductDetail/Texas-Instruments/SN754410NE/?qs=AMJt07B76uuZ4Fb3eRjJ6A%3d%3d&cm_mmc=google-_-ppc-_-americas-_-TI-CoOp&gclid=CjwKEAjwns6hBRDTpb_jkbTv1UYSJACBhberEfKr1cTQmQU0YHhXAWj8i8FYzua_6kk0eghijjVtaRoCC6vw_wcB" rel="nofollow">TI SN754410NE</a> chip... dirt cheap, and can run your stepper in bipolar mode. (<em>Also good for small DC motor drivers</em>.) </p><p>The stepper you are using is actually a gear-motor stepper (<em>looks like the same one I have</em>) so instead of the typical 200 steps per revolution... I'm seeing 4096 steps... which is cool for the project I'm working on. (<em>May have an instructable to follow.</em>)</p><p>Nicely written... great instructable!</p>
<p>Thanks!</p><p>I haven't heard of the gear-motor stepper before...what is the difference between it and a hybrid stepper motor? I was also seeing 4096 on various datasheets for this motor, but when I ran the code on the microcontroller it took 200 times of rotating through the 4 electromagnets to get a full 360 degree rotation. So to me this meant that there was 200 teeth on the internal shaft, for 800 separate electromagnet changes, as opposed to the 4096 steps. Maybe the 4096 steps is for microstepping?</p><p>I actually do have that L293D chip, but I had completely forgotten that I had it. I'll try to add it to this instructable to show off the bipolar mode at some point in the future.</p>
<p>It's pretty simple... they have a series of gears on the output of the stepper... so normally these things are about 200 steps per revolution... so you go through your 1,2,3,4 sequence 50 times and you have made one revolution. But in this case... you have an output gear... so it takes 1024 of your 1,2,3,4 cycles to get one revolution... </p><p>As an added bonus... because it has a gear train in there... you get more output torque for a smaller size stepper... with less current. You do sacrifice speed... but for what I'm doing... that is not an issue.</p><p>(Can you say Pan/Tilt head for a GoPro???)</p><p>Now watch... someone else will beat me to it... :-)</p>
<p>A pair of servos would be a little more practical for a pan/tilt.. (and would also hold position easier). Once you remove power from a stepper motor, it would release position..</p>
<p>Actually, for what I am doing the steppers are better. A servo (<em>common hobby servo</em>) uses a pulse width to determine it's desired location... you must send a constant stream of pulses which the unit converts into an analog voltage and runs through a comparator to drive a DC motor. The accuracy is limited by the width of the pulse, the accuracy of the DC supply line, and the mechanical losses and backlash in the system. A stepper on the other hand can be indexed, then the precise number of steps can be driven. As for a loss of steps, normally you would be correct... however these are gearmotor steppers with a very high accuracy 0.0878 degrees per step, so I'm thinking about a 20:1 gear ratio... a lot of torque would be required... more than the weight of the GoPro in the device. Holding/recovering position is very simple... once the stepper reaches the index (<em>limit switch, etc</em>) you would know the exact number of pulses to send to return to the same location. I need four lines instead of three... and four signals instead of 1, but that's not really an issue for me. I can use a AVR Tiny13 and write a serial input on the remaining line... so I'm back to 3 lines... Supply, Ground, Signal. And I can serially command it to any location instantly. Humm... might be worth an Instructable.</p><p>If you are curious about programming the AVR chips directly...</p><p><a href="https://www.instructables.com/id/Getting-Started-with-Atmel-AVR-and-BASCOM/" rel="nofollow">SHAMELESS PLUG</a>. </p>

About This Instructable




More by JColvin91:Making awesome art for your baby room Pmod Racing Ruler! Float a ping pong ball at will! 
Add instructable to: