Douglas Hebda
Published © GPL3+

Stepper Motor Controller

I needed an easy way to control some stepper motors that I had, so I went to work, and this is what I built.

BeginnerFull instructions provided4 hours29
Stepper Motor Controller

Things used in this project

Hardware components

Arduino Nano Every
Arduino Nano Every
×1
Stepper motor driver board A4988
SparkFun Stepper motor driver board A4988
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Toggle Switch, Toggle
Toggle Switch, Toggle
×1
Capacitor 100 µF
Capacitor 100 µF
×1
DC POWER JACK 2.1MM BARREL-TYPE PCB MOUNT
TaydaElectronics DC POWER JACK 2.1MM BARREL-TYPE PCB MOUNT
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Laser cutter (generic)
Laser cutter (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

A Quick Fritzing Diagram of the Project

A wiring guide to supplement the image

Code

Arduino Code for Stepper Motor Controller

Arduino
int steppin = A5;
int dirpin = A6;
int stepdelay;

void setup() {
  pinMode(steppin, OUTPUT);
  pinMode(dirpin, OUTPUT);
  digitalWrite(dirpin, HIGH); //direction pin either LOW or HIGH to move in either direction
                              //set always high and used a switch and pull-down resistor to achieve a low value at the a4988
  
}

void loop() {
  int val = analogRead(A3);
  stepdelay = map(val,0,1023,300,1600);
  
  if (stepdelay <= 1500) {    //used alternating values to create a step wave
    digitalWrite(steppin, HIGH);
    delayMicroseconds(stepdelay);
    digitalWrite(steppin, LOW);
    delayMicroseconds(stepdelay);
  } else {                    //when the potentiometer is all the way to the right the stepper motor will be turned off
    digitalWrite(steppin, LOW);
  }
}

Credits

Douglas Hebda

Douglas Hebda

1 project • 0 followers

Comments

Add projectSign up / Login