# How to connect a stepper motor with exactly 4 wires to Arduino?

simulate this circuit – Schematic created using CircuitLab

Today I bought a stepper motor to play with, after 12 hours of struggling with it, I haven't been able to figure out how to connect it to an Arduino.

### Is it okay if my stepper motor has exactly 4 wires?

Wires are colored: white, blue, red, yellow. All the pictures and circuits of easy tutorials I found on Google had 5 wires, (and those with 4 wires had different color coding anyway). But a 4-wire doesn't make sense! there must be 2 or 4 poles in a motor, and each pole needs a connection to common ground, so there must be 5 wires, how does a 4 wire work?

### I'm using MOSFET for driving the stepper, not LMxxx

Because I forgot to buy one, and I can't get my hands on one for a couple of days. I use the MOSFETs as fast switches: 4 Arduino pins control 4 MOSFET transistors. And this is exactly the source of confusion: On arduino website, the sample circuit's stepper has 4 wires and is directly connected to a driver IC (a LMxxx), and the driver is connected to Arduino. Since I do not have a driver at hand, I need to convert the circuit so it works with 4 transistors instead. But what the wiring should be? If it had 5 wires I would have done it like this schematics.

It is very likely there are problems with my PNP/NPN Mosfet choice, but as soon as I know how to wire the circuit, I'll choose the right one!

• does your stepper have 4 wires? it's probably 2 poles, with 2 pins per pole. You rig up your own external FETs as switches to switch current through the poles (in one pin, out the other pin for that pole). – KyranF Mar 14 '15 at 20:46
• What is your MOSFET part number? You DO realize that P channel FETs need a different way to drive them right? – KyranF Mar 14 '15 at 20:46
• Perhaps you just labelled/showed the FETs wrong, but I think you should try just doing low-side N-FETs and get that working. Who needs two directions anyway? lulz – KyranF Mar 14 '15 at 20:51
• i'll have to investigate it further before I can post an answer for you, to verify that it's possible. I will have to re-read all the info about stepper motors, and while i'm doing that so should you! :) – KyranF Mar 15 '15 at 17:09
• so your solution was to get a L293D and rig it up as a stepper driver? Be careful about the max current of the stepper motor, they can be quite high current and you may blow up the L293D without some good heat sinking – KyranF Mar 16 '15 at 6:01

Your motor is Bi-polar. It has two windings and you need to use a circuit that constantly inverts the polarity of the supply to the coils.

This is done with an H-bridge that operates as four switches.

You need one H-bridge per coil, so you'll need two of them to control your stepper. In practice these switches are either mosfets or transistors.

Refer to the below articles for stepper motor driving:
http://www.8051projects.net/stepper-motor-interfacing/introduction.php
http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/

It sounds like you have a "Bipolar" stepper motor.

Stepper motors come in two flavours: Bipolar and Unipolar.

Unipolar ones are much easier to work (but more expensive to make) with as it's just a matter of turning the right coils on and off in the right order - so most simple tutorials are for those.

Bipolar ones, though, require a pair of H-bridges to get them working properly. Not only to you have to turn the coils on and off in the right order, but you have to switch them to the right polarity at the right time.

I don't normally recommend instructables as some of the things on there are downright dangerous, but there is an example on there of driving a bipolar stepper motor from an Arduino: http://www.instructables.com/id/Bi-Polar-Stepper-Motor-with-L293D-and-Arduino/

• Can a motor with 2 wires be controlled with a driver that takes 4 or 6 wires ? – O.Rares Apr 7 '18 at 7:46