LogoLogo
Terminal
  • Attic Lab
  • Getting Started
  • Crest Gold
  • Crest Silver
  • Videos on Computation
  • PI PICO (CIRCUITPYTHON)
    • Getting Started
    • Pin Out Diagram
    • Breadboards
    • 1. Led Blink
    • 2. RGB
    • 3. OLED
    • 4. Sensors
    • 5. Wifi
    • 6. Servos
  • Arduino
    • Getting Started
    • Pin Out Diagrams
      • Mega2560 R3
    • Programming
      • Arduino C - Cheat Sheet
    • Buttons
      • Momentary Switches
    • Display
      • LEDs
      • 7 Segment Displays
      • LCD Displays (GPIO)
      • LCD Displays (SPI)
      • OLEDs
    • Communication
      • Antenna Theory
      • Lora
      • Wifi
        • Boards
    • Project Ideas
    • Motion
      • DC Motors
      • Servo Motors
      • Stepper Motors
  • Microsoft Office
    • Word
    • Powerpoint
    • Excel
  • The Terminal
    • Basics
    • Cheat Sheet
    • Games
      • Level 1 - Bashcrawl
      • Level 2 - Bandit
  • TinkerCad
    • Gallery
    • Getting Started
    • Basic Operations
    • Basic Skills
    • Projects
      • Locking Container
  • Python
    • Hello World
    • Turtle Graphics
      • Strings in Turtle Graphics
      • Cheat Sheet
    • Variables
    • Loops
    • If Statements
    • Functions
    • Games
      • Pong
  • Raspberry Pi
    • Setup
      • Changing The Hostname
      • Headless Setup
      • Kiosk Mode
    • Remote Connections
    • Displays
      • Memory
        • External HD
      • HyperPixel 4.0
  • Ultimaker 3D Printing
    • The Thingiverse
    • Preparing the File
    • Printing
    • Calibration Prints
    • Print Set
  • Fusion 360
    • Getting Started
    • Design Tutorials
      • Tweezers
      • Mars Rover Wheel
    • Surface Modeling
  • Electronics
    • References
    • Antenna Theory
    • LoRa
  • PCB Milling
    • FlatCam
    • Candle
    • PCB Milling
  • Projects
  • Projects
    • Star Map Necklace
    • Ideas Respository
  • Latex
    • What is LaTeX?
    • Getting Started
    • Structure
    • Page Size & Margins
    • Styling
    • Images
    • Lists
    • Tables
    • Mathematics
      • Superscript and Subscripts
      • List of Symbols
      • Fractions and Binomials
      • Integrals, Sums & Limits
    • Colors
  • Web Development
    • The Internet
    • Intro to HTML
    • Basic Elements
    • Basic Styling
Powered by GitBook
On this page
  • Introduction
  • Stepper motors vs standard DC motors?
  • Stepper motors vs servo motors?
  • Advantages of stepper motors
  • Why a Driver Board is Needed
  • The ULN2003 Driver Board
  • Schematic
  • The Arduino Stepper Library
  • Further Reading

Was this helpful?

  1. Arduino
  2. Motion

Stepper Motors

Stepper motors fall somewhere in between a regular DC motor and a servo motor. They have the advantage that they can be positioned accurately, moved forward or backwards one 'st

PreviousServo MotorsNextWord

Last updated 4 years ago

Was this helpful?

This tutorial uses a ULN2003A stepper motor driver chip. Other drivers do exist and operate on the same principles e.g L293D or a ULN2803. See the further reading section for a tutorial on these last two

Introduction

A stepper motor converts electrical pulses into discrete mechanical rotation. That is because when electrical signals are applied, the stepper motor rotates in accurate and fixed angle increments known as steps. The motor consists of 4 coils that make a ring around the rotor. These coils are known as the stator, as they are stationary and static. Each coil is rated at +5V, making it easy to control with any microcontroller, such as an Arduino.

Stepper motors vs standard DC motors?

  1. The rotation of stepper motors is incremental, slow and precise, while DC motors have a fast, continuous motion.

  2. Stepper motors are known to generate some noise during operation while DC motors are quiet and relatively vibration-free.

  3. The response time of the stepper motor is slower than the DC motor.

  4. Stepper motors can be easily controlled with microprocessors like the Arduino. Compared to DC motors, they are more mechanically simple and easy to design and build. In contrast, DC motors are not so easily controlled with microprocessors

Stepper motors vs servo motors?

  1. Stepper motors can move more accurately and precisely than the servo motor and are much easier to control.

  2. Stepper motors are more suitable for applications with lower speeds of less than 2000 rpm (revolutions per minute), and servos are best suited for applications with high speeds greater than 2000 rpm.

  3. Stepper motors operate at lower speeds than servo motors.

  4. Stepper motors are cheaper than servo motors as they are less mechanically complex.

Advantages of stepper motors

  • Precise Positioning – Stepper motors move in precise steps. As such, they do well in applications that require precise positionings, such as 3D printers and camera platforms.

  • Precise Speed control – Precise increments in movements enable excellent control of rotational speed for process automation and robotics.

  • High Torque at low speeds – Stepper motors are best suited for applications with low speed (less than 2000 rpm) as they have maximum torque at low speeds. In contrast, normal DC motors and servo motors do not have so much torque at low speeds.

  • Easy to control – Stepper motors can easily be controlled using a microcontroller like an Arduino. In fact, its ease of use has also been a major reason for its continued usage by stepper motor users.

  • Cheap – In applications where stepper motors would suffice, and using one could help you to realize better cost savings.

Why a Driver Board is Needed

A stepper stepper motor consumes high current and hence, we will need to use a driver IC in order to control the motor with a microcontroller like the Arduino.

For example, a stepper motor that needs 9V and 300mA to operate cannot be powered by an Arduino. Hence, we connect this IC to source for enough current and voltage for the motor. If you have to power anything more than 5V and 80mA, a driver board should be used.

Take note that powering the stepper motor directly from the Arduino is not recommended

The ULN2003 Driver Board

Known for its high current and high voltage capacity, the ULN2003 gives a higher current gain than a single transistor and enables the low voltage and low current output of a microcontroller to drive a higher current stepper motor.

As shown in the diagram below, a ULN2003 driver board consists of a ULN2003 soldered onto a board, together with resistors, capacitors, and other bits and bobs that help create the circuit that takes the pulse signals from the controller and converts them into stepper motor motion.

Some boards have a switch / jumper that lets you toggle whether the motor get's it's +5V from the Arduino or an external supply.

Schematic

The Arduino Stepper Library

Note that the Stepper constructor does not takes the pins in order IN1, IN2, IN3, IN4, but rather IN1, IN3, IN2, IN4.

On the Ariduino Mega I was unable to get the stepper motor working on the purely digital pins 22-53. Not sure why.

// Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board and Arduino UNO.

// Include the Arduino Stepper.h library:
#include <Stepper.h>

// Define number of steps per rotation:
const int stepsPerRevolution = 2048;

// Wiring:
// Pin 8 to IN1 on the ULN2003 driver
// Pin 9 to IN2 on the ULN2003 driver
// Pin 10 to IN3 on the ULN2003 driver
// Pin 11 to IN4 on the ULN2003 driver

// Create stepper object called 'myStepper', note the pin order:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
  // Set the speed to 13 rpm: 13 rpm seems to be the maximum speed
  myStepper.setSpeed(13);
  
  // Begin Serial communication at a baud rate of 9600:
  Serial.begin(9600);
}

void loop() {
  // Step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  
  // Step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}

Further Reading

The ULN2003 is one of the most common motor driver ICs that houses an array of 7 pairs, each capable of driving loads up to 500mA and 50V. Basically, a Darlington pair is a pair of transistors, where the second transistor amplifies the output current of the first transistor. The ULN2003 IC is needed to drive the motor with an Arduino, but they come in convenient and cheap driver boards that are readily available complete with indicator LEDs. So it’s better to grab one of these rather than breadboarding the IC itself.

Darlington transistor
Pin Out diagram for the ULN2003
Connecting the stepper motor to an external supply
Darlington Transistor and the Sziklai Darlington PairBasic Electronics Tutorials
28BYJ-48 Stepper Motor with ULN2003 + Arduino (4 Examples)Makerguides.com
Arduino - Stepper
Arduino and Stepper Motor Configurations | Arduino Documentation
Logo
Adafruit's Raspberry Pi Lesson 10. Stepper MotorsAdafruit Learning System
Logo
GitHub - tyhenry/CheapStepper: Arduino library for the cheap but decent 28BYJ-48 5v stepper motor with ULN2003 boardGitHub
Logo
Logo
Logo