Use a Potentiometer to control a Stepper Motor
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.
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.
Copy the above Sketch code in your Arduino IDE software to program your Arduino.
(AccelStepper Library created by Mike McCauley at http://www.airspayce.com/mikem/arduino/AccelStepper/)
Once downloaded, just extract the content of the zip files inside your “arduino libraries” folder.