top of page

Arduino with Stepper Motor

Stepper motor


A stepper motor is a brushless DC electric motor that divides a full rotation into a number of equal steps. The motor's position can then be commanded to move and hold at one of these steps without any position sensor for feedback (an open-loop controller). The stepper motor is known for its property of converting a train of inputs pulses (typically square waves) into a precisely defined increment in the shaft's rotational position. The motors rotation has several direct relationships to these applied input pulses.

stepper motor.jpg

Stepper motor with ULN2003A driver board

pros
Due to their high pole count, stepper motors offer precision drive control for motion control applications, they have a high torque at low speeds, and they are relatively inexpensive and widely available.

​

cons
At high speeds, stepper motors lose nearly all their torque, sometimes up to 80%. They produce high vibrations and are prone to resonance issues in certain applications. They are typically digitally controlled as part of an open loop system for use in holding or positioning applications. Commercially, stepper motors are used in flatbed scanners, computer printers, plotters, CHC machines, 3D printers etc.

​

To interface the stepper motor with the Arduino, we will need breakout for ULN2003A transistor array chip. Here, we will use the 28BY-48 stepper more and program our stepper motor to turn in clockwise and counterclockwise directions.

Schematic

stepper-28byj48-arduino-wiring.png

Sketch

​

#include <Stepper.h>

 

// change this to fit the number of steps per revolution of your motor
const int stepsPerRevolution = 2048;  

​

// Adjustable range of 28BYJ-48 stepper is 0~17 rpm
const int rolePerMinute = 15;        

​

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

​

void setup() {
  myStepper.setSpeed(rolePerMinute);
  // initialize the serial port:
  Serial.begin(9600);
}

​

void loop() {  
  // step one revolution in one direction:
  myStepper.step(stepsPerRevolution);
  delay(500);

​

  // step one revolution in the other direction:
  myStepper.step(-stepsPerRevolution);
  delay(500);
}

bottom of page