Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
DIY GUY ChrisBob AlsoneJLCPCB
Published © Apache-2.0

Large Stepper Motor Control A4988

Ultimate getting started guide to easily understand how stepper motor work and how to properly control using an Arduino board

BeginnerFull instructions provided12 hours30,454
Large Stepper Motor Control A4988

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
Control unit of our project
×1
Stepper motor driver board A4988
SparkFun Stepper motor driver board A4988
The stepper motor that we have used in our tutorial
×1
Stepper Motor
Digilent Stepper Motor
×1
Driver DRV8825 for Stepper Motors for Theremino System
Driver DRV8825 for Stepper Motors for Theremino System
Optional Driver to use instead of A4988
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1

Software apps and online services

EasyEDA
JLCPCB EasyEDA
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic PDF format

Download this file to acces the schematic PDF format

Code

Code snippet #1

Plain text
const int EN=2;         //ENABLE PIN
const int Step=3;       // STEP PIN
const int dir=4;        // DIRECTION PIN
/*----------------------------SETUP FUNCTION--------------------------*/
void setup() 
{
  pinMode(EN,OUTPUT);     // ENABLE AS OUTPUT
  pinMode(dir,OUTPUT);    // DIRECTION AS OUTPUT
  pinMode(Step,OUTPUT);   // STEP AS OUTPUT
  digitalWrite(EN,LOW);   // SET ENABLE TO LOW
}

/*----------------------------LOOP FUNCTION--------------------------*/
void loop() 
{
  digitalWrite(dir,LOW);        // SET DIRECTION LOW FOR FORWARD ROTATION
  for(int x = 0; x < 1000; x++) // LOOP 1000 TIMES FOR 1000 RISING EDGE ON STEP PIN
  {
    digitalWrite(Step,HIGH);    // STEP HIGH
    delay(1);                   // WAIT
    digitalWrite(Step,LOW);     // STEP LOW
    delay(1);                   // WAIT
  }
  delay(10);                    // DELAY BEFOR SWITCH DIRECTION
  digitalWrite(dir,HIGH);       // SET DIRECTION HIGH FOR BACKWARD ROTATION
  for(int x = 0; x < 1000; x++) // LOOP 1000 TIMES FOR 1000 RISING EDGE ON STEP PIN
  {
    digitalWrite(Step,HIGH);    // STEP HIGH
    delay(1);                   // WAIT
    digitalWrite(Step,LOW);     // STEP LOW
    delay(1);                   // WAIT
  }
  delay(10);                    // DELAY BEFOR SWITCH DIRECTION
}

Credits

DIY GUY Chris

DIY GUY Chris

51 projects • 342 followers
I'm having fun while making electronics projects, I am an electrical engineer in love with "Do It Yourself" tasks.
Bob Alsone

Bob Alsone

8 projects • 4 followers
JLCPCB

JLCPCB

73 projects • 42 followers
JLCPCB, is the largest PCB and PCB Assembly prototype enterprise in Asia. Coupon code "JLCPCBcom" for all and permanantly available.
Thanks to EasyEDA .

Comments