How to control a stepper motor using a computer

Written by david gitonga
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to control a stepper motor using a computer
Stepper motors can be precisely controlled using a computer. (motors image by Dusan Radivojevic from

Stepper motors are electromechanical devices that can be accurately controlled without the need for feedback information to know their position. This means that stepper motors do not need sensing and feedback devices, and their positions can simply be determined by keeping track of the input pulses fed to them. They can be controlled to move slowly, quickly, in reverse, and they can pause or do partial and complete revolutions to the accuracy of less than a degree. They are used where precise motion and position control to precise angles is of utmost importance. A number of methods exist for controlling stepper motors from a computer.

Skill level:

Other People Are Reading

Things you need

  • Stepper motor
  • ULN2003 IC
  • Multimeter
  • DB-25 male connector
  • DB-25 female / male parallel port cable
  • Power adaptor
  • Solder-less breadboard

Show MoreHide


  1. 1

    Lay out the circuit for the motor on the breadboard as shown on the circuit in the article "Computer Controlled Stepper Motor" (see Resources: Channel 9).

  2. 2

    Label the stepper motor wires using your multimeter to determine the common power wire that carries current (see Resources: Identifying the Common Power Wire in Stepper Motors).

  3. 3

    Solder the DB-25 male connector to the connecting wires on the board and ensure all connections are correct using a multimeter. This makes it easier to plug and unplug. Test all connections to ensure there are no short-circuits and then plug the connector to the computer when all is fine.

  4. 4

    Write the code that will be used to control the motor. The code can be written in either C# or in Visual Basic (VB). The following sample code uses the "InpOut32.dll" library file found in the "Systems32" folder of Windows systems:


    private class PortAccess


    [DllImport("inpout32.dll", EntryPoint="Out32")]

    public static extern void Output(int address, int value);



    Private Class PortAccess

    Public Declare Sub Output Lib "inpout32.dll" Alias "Out32" (ByVal address As Integer, ByVal value As Integer)

    End Class

Tips and warnings

  • Stepper motors can also be controlled via the USB. All you need is a StepperBee USB adaptor board and then use the installation disk to make the configurations. Alternatively, USB adaptor installation disks come with a DLL (Dynamic Link Library) that allows standard functions to be called using a wide range of languages without having to know USB operation details.
  • By learning how to reach and control external devices using the parallel port, you will find it both easy and interesting when it comes to stepper motors. The same procedure applies to controlling LEDs with a Parallel Port.
  • The parallel port can be easily damaged if wrong connections are made. Damaged embedded parallel ports require a motherboard replacement. It is thus recommended to have an I/O card with a parallel port and use it for testing purposes.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.