Introduction: How to Interface Stepper Motor With Arduino and Stepper Motor Driver

This tutorial is going to teach you some basics on using Stepper Motor while interfacing with Arduino and Stepper Motor Driver.

Step 1: Introduction


Bipolar Stepper Motor is DC motor that move in discrete steps. It has multiple coils that are organized in groups called "phases". By energizing each phase in sequence, the motor will rotate, a step at a time. In order to be able to move the motor, you will need a motor driver. Thus, stepper motor driver A4988 is designed to play this role. A4988 stepper motor driver comes with heat sink. This stepper motor driver lets you control one bipolar stepper motor at up to 2 A output current per coil.

Specificaations of Bipolar Stepper Motor:

  • Origin: China
  • Model: 42HD04
  • Low cost, small size
  • Bipolar
  • 4 lead wire
  • 1.8 deg/ step
  • Torque:
  • Size: 33mm x 42mm x 42mm
  • Voltage being applied and test: 6V to 12V

Specifications of Stepper Motor Driver A4988:

  • Simple step and direction control interface
  • Five different step resolutions: full-step, half-step, quarter-step, eight-step, sixteen-step
  • Adjustable current control lets you set the maximum current output with a potentiometer which lets you use voltage above your stepper motor's rated voltage to achieve higher step rates.
  • Intelligent chopping control that automatically selects the correct current decay mode (fast decay or slow decay)
  • Over-temperature thermal shutdown, under-voltage lockout, and crossover-current protection
  • Short-to-ground and shorted-load-protection
  • Dimension: 20mm x 15mm x 10mm

Step 2: Pin Definition

Step 3: Sample Hardware Installation

Step 4: Sample Source Code

To get the result, please download the sample source code attached below and upload it into Arduino.

Step 5: Procedure (1)

This example is done by driving the 42 Step Stepper Motor device using the Arduino UNO via A4988 Stepper Motor Driver Module. Before connecting the motor power supply to the module, the sample source code must be uploaded first into the Arduino UNO board via USB 2.0 type A male to type B male cable.

Step 6: Procedure (2)

Next, adjust the current limiting of the driver by using the potentiometer on board. This is to make sure that the current is within the current limits of the motor ranges from 0mA to 2000mA (2A).

In order to prevent damage to both of the motor and driver module, the current must actively be limited to under 1A. In full step mode, the current through the coils is limited to 70% of the current limit, so to get a full-step coil current of 1 A, the current limit should be 1 A/0.7=1.4 A, which corresponds to a Vref of 1.4 A/2.5=0.56 V. Please refer to the A4988 datasheet for more information. The current limit relates to the reference voltage is as follow:

Current Limit = Vref / (8 x Rs)

  • Rs = Sense Resistor
  • Vref = input voltage on the REF pin.

Because of different stepper motor has their own specification, so please check the motor’s datasheet for the current settings. In this example, the Vref (voltage references) is set to about 0.4 V, so the current limit is 1 A. You can measure the Vref of the module by attaching the multimeter probes between the center of the potentiometer and the ground pin that is connected to the Arduino board.

Step 7: Procedure (3)

The USB cable that is used to upload the source code can now be disconnected. Next, connect the motor power supply (Li-on Battery, 7.4 V, 1200mAh) to the module through the power jack. The stepper motor will start to rotate clockwise and anticlockwise according to the given sample source code.

Step 8: Video