Code to Control Stepper Motors

The code to control stepper motors will depend on a couple of things:

  • The type of stepper motor - bipolar / unipolar
  • The stepper motor controller
  • The Arduino library you choose to use
    I would definitely recommend looking into the AccelStepper library for controlling multiple motors, using non-blocking code and having more advanced functions.

I messed around with stepper motors recently and documented the results on my blog, with sample code and wiring. Hope you find those useful:
Stepper motor wiring tutorial
Bipolar stepper motor control with Arduino and an H-Bridge
28BYJ-48 Unipolar Stepper Motor with ULN2003 driver and Arduino Uno