Stepper Motor Control with Potentiometer

First watch this tutorial:

How To Control a Stepper Motor with L293D Motor Driver


This tutorial is all about tuning the speed of a stepper motor using a potentiometer. The idea is to up or down the speed of a stepper motor using with analog read. Theoretically analog input to a digital output, we're going to use this concept to control the speed of a running stepper motor.

The Stepper motor used here is a rusty old EPOCH (5 wires) stepper motor, which is a unipolar stepper.

Use the analog input with the help potentiometer to control the delay in-between each steps of the stepper motor. Shorter the delay in-between each steps - faster the stepper motor runs and vice-versa.

Hardware Required :

- 10k Potentiometer

Recommended site to buy the required hardware:

Get the Code:
 // input pin for the potentiometer
int read_potentiometer = A0;

// input pin for the LED
int LED_pin = 13;

// input pin for the Step Motor 
int step_pin_1 = 8; 
int step_pin_2 = 9; 
int step_pin_3 = 10; 
int step_pin_4 = 11;

float delay_time;
int value_potentiometer = 0;

void setup()

void loop() 

value_potentiometer = analogRead(read_potentiometer); 

   if (value_potentiometer >  0   ){
      delay_time=0;    // Minumum speed when it is 0


digitalWrite(LED_pin, HIGH);  
digitalWrite(8, HIGH); digitalWrite(step_pin_2, HIGH); digitalWrite(step_pin_3, LOW); digitalWrite(step_pin_4, LOW);   

digitalWrite(LED_pin, LOW); 
digitalWrite(step_pin_1, LOW); digitalWrite(step_pin_2, HIGH); digitalWrite(step_pin_3, HIGH); digitalWrite(step_pin_4, LOW);  

digitalWrite(LED_pin, HIGH); 
digitalWrite(step_pin_1, LOW); digitalWrite(step_pin_2, LOW); digitalWrite(step_pin_3, HIGH); digitalWrite(step_pin_4, HIGH);  

digitalWrite(LED_pin, LOW);   
digitalWrite(step_pin_1, HIGH); digitalWrite(step_pin_2, LOW); digitalWrite(step_pin_3, LOW); digitalWrite(step_pin_4, HIGH);