I'm having trouble using the ENABLE pin on my microstepper driver, I'm not sure of the exact model but it looks exactly like the one pictured here

Microstepper Driver

Here's my code:

#define MAX_LEN 8
#define MIN_INCREMENT 0.5
#define LIMIT_SWITCH 3
#define ENABLE 10
float buoyancymass = 4401.425;
float centrebuoyancy = 14.164;
float mainarm = 14.3;
float nosearm = 1.8;
float adc = 11.4;
float meanadc = 22.65; 
volatile byte enable_state = LOW;

#include <Stepper.h>

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

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

int stepCount = 0;         // number of steps the motor has taken
float stepinch = 0.00524; // 1 step = x"

void setup() {
  // initialize the serial port:
  pinMode(ENABLE, OUTPUT);
  //enable motor
  digitalWrite(ENABLE, enable_state);
  attachInterrupt(digitalPinToInterrupt(LIMIT_SWITCH), limitbrake, FALLING);
  // set the speed

void limitbrake() {
  digitalWrite(ENABLE, !enable_state);

The problem I'm noticing is that when I set the pinMode(ENABLE,OUTPUT); my stepper doesn't draw current and therefor, doesn't drive. This occurs regardless of whether I set my enable_state to HIGH or LOW.

Funny enough, when I set it to pinMode(ENABLE,INPUT); it does draw current and drive the motor, but unfortunately my limit switch which I've attached an interrupt to doesn't disable the motor when its pressed.

Before you ask, I've tested the enable pin on my driver and my limit switch circuitry in other programs and they both work. I'm just having trouble with putting it together.

Here is the rest of my code if you were wondering.

float calc_margin(float pos, float mass) {
  // calculate margin
  Serial.print("Distance: ");Serial.println(pos);
  float batterymoment = mass*pos;
  float totalmass = mass + 12404;
  float totalmoment = 149650+batterymoment;
  float buoyancymoment = buoyancymass*centrebuoyancy;
  float wheelmoment = totalmoment - buoyancymoment;
  float wheelweight = totalmass - buoyancymass;
  float cgwheels = wheelmoment/wheelweight;
  float maindistance = mainarm - cgwheels;
  float nosedistance = cgwheels - nosearm;
  float mainmass = (((wheelweight)*(1-((maindistance)/(maindistance+nosedistance))))/2);
  float nosemass = (((wheelweight)*(1-((nosedistance)/(nosedistance+maindistance))))/2);
  float mainmoment = mainmass*mainarm;
  float nosemoment = nosemass*nosearm;
  float netmoment = buoyancymoment+(mainmoment*2)+(nosemoment*2);
  float netcg = netmoment/totalmass;
  float staticmargin = adc - netcg;
  float answer = staticmargin/meanadc;
  float percentage = answer*100;
  Serial.print(percentage); Serial.println("%");
  float result = answer;
  return result;

boolean check_margin(float test_margin) {
  if (test_margin > -0.04 && test_margin < -0.02)
    return true;
  return false;

float armcalc(float mass) {
  for(float x=0;x<MAX_LEN;x+=MIN_INCREMENT) {
    // calculate margin
    float margin = calc_margin(x,mass);
    if (check_margin(margin)) {
      return x;
  return -1;

float stepcalc(float arm){
  int arminch = arm*12;
  float numberofsteps = arminch/stepinch;
  int result = numberofsteps;
  Serial.print("Calculated steps: "); Serial.println(result);
  return result;

void loop() {
  // read input
  Serial.println("Enter mass: ");
  while (!Serial.available());
  float mass = Serial.parseFloat();
  float arm = armcalc(mass);
  if (arm < 0) {
    // Error message
  Serial.print("Arm distance is "); Serial.println(arm);
  // step
  const int steplength = (int) stepcalc(arm);
  Serial.print("Number of steps is "); Serial.println(steplength);


  • An interrupt service routine which toggles state sounds like you are just asking for trouble. Even if it is not the cause of your problem, you would likely be better off with logic to assertively set the correct level. Are you aware of the issue of "contact bounce"? That could see you toggle the motor state a somewhat random number of times, with the result depending if that is even or odd... Apr 14, 2016 at 19:48
  • I drive those with 12 Volts from a printer port. I remember mine should be also 5V-compatible. Plus, I have the feeling, that you don't exactly know, how these drivers work...
    – moestly
    Apr 14, 2016 at 19:54

1 Answer 1


These drivers differ from the H-Bridge-design described here. You don't need to generate pulses for the coils, as you would do with a classic H-Bridge.

  1. Connect your motor to A+, A-, B+, B- (a is one coil, b the other)

  2. Connect Power (guess 12+ volts, mine take up to 48V) to GND and V+

  3. Either connect 5V to ENA+(+5V) or a free arduino Pin and ENA-(ENA) to GND. This pin enables/disables the driver. If no input is present at this pin, the driver will not work.

  4. Connect DIR+(+5V) to a free arduino pin and DIR-(DIR) to GND. This pin controls the direction. HIGH makes the motor turn right, while LOW on this pin makes the motor turn left.

  5. Connect PUL+(+5V) to a free arduino pin and PUL-(PUL) to GND. This pin controls the speed. The more pulses/second one applies, the faster the motor turns. (Up to a limit, of course).

Sketch should be easy.

Plus: You could turn around the control connections, by hardwiring all +5V pins to 5V and use INPUT_PULLUP to switch the current flow on the negative lines. I know that these drivers are optical isolated and draw as little as 10 mA from a pin, if at all. So you should be safe.

  • I fixed the enable function and I'm able to control the motor, but I'm still unable to use my limit switch to set the enable pin on or off. Would you have any idea as to why that is?
    – Jertise
    Apr 14, 2016 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.