Skip to main content

Using NEMA17 Stepper motor with Big Easy Driver

What is NEMA17 Stepper motor?

A NEMA 17 stepper motor is a compact, precise motor commonly used in 3D printers, CNC machines, and robotics. “NEMA 17” refers to its 1.7 × 1.7 inch mounting face size, while the stepper design allows it to move in fixed steps (typically 200 per revolution), making it ideal for accurate position control without feedback sensors.

What is Big Easy Driver?

The Big Easy Driver is a stepper motor driver board based on the A4988 chip, used to control stepper motors like NEMA 17 with microcontrollers such as Arduino. It allows easy control of motor speed, direction, and microstepping while handling higher current safely and efficiently. Know More

Wiring

Before wiring, you need to figure out the wire pairs for each coil on the motor you plan to use. You can usually find this information from the datasheet. In this tutorial, we are using a 4-wire NEMA17 motor with no polarity on the coil.

Uno → Big Easy Driver

  1. D2 → STEP
  2. D3 → DIR
  3. D4 → MS1
  4. D5 → MS2
  5. D6 → MS3
  6. D7 → ENABLE
  7. GND → GND

Motor → Big Easy Driver

  1. Black → A
  2. Green → A
  3. Red → B
  4. Blue → B
  5. 12V power + → M+
  6. 12V power - → GND

Get started

This example code demonstrates 4 modes: forward, reverse, 1/16th microstep and alternate directions.

//Declare pin functions on Arduino
#define stp 2
#define dir 3
#define MS1 4
#define MS2 5
#define MS3 6
#define EN  7

//Declare variables for functions
char user_input;
int x;
int y;
int state;

void setup() {
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(MS1, OUTPUT);
  pinMode(MS2, OUTPUT);
  pinMode(MS3, OUTPUT);
  pinMode(EN, OUTPUT);
  
  resetBEDPins(); //Set step, direction, microstep and enable pins to default states
  Serial.begin(9600); //Open Serial connection for debugging
  Serial.println("Begin motor control");

}

//Main loop
void loop() {
  StepForwardDefault();    
  ReverseStepDefault(); 
  SmallStepMode(); 
  ForwardBackwardStep();
}

//Reset Easy Driver pins to default states
void resetBEDPins(){

  digitalWrite(stp, LOW);
  digitalWrite(dir, LOW);
  digitalWrite(MS1, LOW);
  digitalWrite(MS2, LOW);
  digitalWrite(EN, HIGH);
}

//Default microstep mode function
void StepForwardDefault(){

  Serial.println("Moving forward at default step mode.");
  digitalWrite(EN, LOW); //Pull enable pin low to set FETs active and allow motor control
  digitalWrite(dir, LOW); //Pull direction pin low to move "forward"
  for(x= 0; x<1000; x++)  //Loop the forward stepping1000 enough times for motion to be visible
  {steps
    digitalWrite(stp,HIGH); //Trigger one step forward
    delay(1);
    digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again
    delay(1);
  }
  resetBEDPins();
}

//Reverse default microstep mode function
void ReverseStepDefault(){

  Serial.println("Moving in reverse at default step mode.");
  digitalWrite(EN, LOW); //Pull enable pin low to set FETs active and allow motor control
  digitalWrite(dir, HIGH); //Pull direction pin high to move in "reverse"
  for(x= 0; x<1000; x++)  //LoopReverse the1000 stepping enough times for motion to be visiblesteps
  {
    digitalWrite(stp,HIGH); //Trigger one step
    delay(1);
    digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again
    delay(1);
  }
  resetBEDPins();
}

// 1/16th microstep forward mode function
void SmallStepMode(){

  Serial.println("Stepping at 1/16th microstep mode.");
  digitalWrite(EN, LOW); //Pull enable pin low to set FETs active and allow motor control
  digitalWrite(dir, LOW); //Pull direction pin low to move "forward"
  digitalWrite(MS1, HIGH); //Pull MS1,MS2, and MS3 high to set logic to 1/16th microstep resolution
  digitalWrite(MS2, HIGH);
  digitalWrite(MS3, HIGH);
  for(x= 0; x<1000; x++){ //Loop1000 the forward stepping enough times for motion to be visible
  {steps
    digitalWrite(stp,HIGH); //Trigger one step forward
    delay(1);
    digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again
    delay(1);
  }

  resetBEDPins();
}
//Forward/reverse stepping function
void ForwardBackwardStep(){

  Serial.println("Alternate between stepping forward and reverse.");
  digitalWrite(EN, LOW); //Pull enable pin low to set FETs active and allow motor control
  for(x= 1; x<5; x++)  //Loop the forward stepping enough timesalternate for motion5 to be visibletimes
  {
    //Read direction pin state and change it
    state=digitalRead(dir);
    if(state == HIGH)
    {
      digitalWrite(dir, LOW);
    }
    else if(state ==LOW)
    {
      digitalWrite(dir,HIGH);
    }

    for(y=0; y<1000; y++){ {//1000 steps each time
      digitalWrite(stp,HIGH); //Trigger one step
      delay(1);
      digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again
      delay(1);
    }
  }
  resetBEDPins();
}