top of page

Safari browser sometimes has issues displaying images...

I.e: *you have to click on the images to see them...

For a better browsing experience on Brainy-Bits

Please use Chrome, Edge or Firefox browser.

  • Writer's pictureBrainy-Bits

Control a Stepper motor using an Arduino and Potentiometer


Sometimes keeping things simple is best!

In this tutorial we will see how to move a stepper using only a regular Potentiometer.

We will use a NANO and the Easy driver to control the NEMA 17 stepper motor.



EasyDriver Stepper Driver

Arduino NANO

Stepper Motor NEMA 17

10K Potentiometer

These are Amazon affiliate links...

They don't cost you anything and it helps me keep the lights on

if you buy something on Amazon. Thank you!



Connections for this tutorial are as follow:

Pin 2 and 3 of the NANO are connected to the STEP and DIR pin of the Easy Driver

We also connect a Ground pin of the NANO to the Easy Driver GND pin

Pin A4 of the NANO is used to read the Analog value of the Potentiometer Center pin

5V and GND of the NANO are connected to the outer pins of the Potentiometer

We then power the Easy Driver, thus powering the Stepper Motor, using an external 12v power supply.



We will be using the AccelStepper library to control the speed and acceleration of the stepper motor, we want the motor to move in relation to the rotation of the Potentiometer.

Since a Potentiometer can change value even when we are not touching it, we are moving the motor only if the Potentiometer value has changed +6 or -6 from the previous read value, that way we avoid jitter of the Stepper motor.

As always please have a look at the tutorial video for more information.

/* Arduino Stepper Control with Potentiometer

Created by Yvan /
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!


#include "AccelStepper.h" 
// Library created by Mike McCauley at

// AccelStepper Setup
AccelStepper stepper(1, 2, 3);  // 1 = Easy Driver interface
                                  // Nano Pin 2 connected to STEP pin of Easy Driver
                                  // Nano Pin 3 connected to DIR pin of Easy Driver

// Variables to store current, previous and move position
int val = 0;
int previous = 0;
int long newval = 0;    

void setup() {
  stepper.setMaxSpeed(4800);  // Set speed fast enough to follow pot rotation
  stepper.setAcceleration(4800);  //  High Acceleration to follow pot rotation  

void loop() {
  val = analogRead(A4);  //  Read Potentiometer current value
  if ((val > previous+6) || (val < previous-6)) {  // Check that a move of the pot is at least > or < than 6
    newval = map(val, 0, 1023, 0, 1600);  // Map value (1600 = 1 stepper shaft rotation)
    stepper.runToNewPosition(newval);  // Move stepper to new position
    previous = val;  // save current value into variable previous





Copy the above Sketch code in your Arduino IDE software to program your Arduino.

(AccelStepper Library created by Mike McCauley at

12,931 views0 comments


All my content is and will always be Free.

If you feel that my Videos / Tutorials are helping, and you would like to contribute...

 You can toss some coins in the Tip Jar via PayPal.

Select amount then click the “Donate” button.

bottom of page