I want to Use LEONARDO PRO MICRO and A4988 Stepper Motor DRIVER to control Nema 17 Stepper Motor.

enter image description here enter image description here

Please let me know how to hookup these together.

Please give me a circuit for this type of assembly with Arduino code.

1 Answer 1


You can simply make a google search; Wiring instructions

Here is some code to get you started

// Declaration of variables
#define Step 7     // Pin that transmits the "step" order to the board
#define Dir  6     // Pin that indicates the direction of the rotation
int vit  =   10 ;   // Speed of the rotation (smaller means faster rotation)
int sens =   1  ;  // Rotation direction (0 or 1)

void setup()
  pinMode( Step  , OUTPUT );
  pinMode( Dir   , OUTPUT );
void loop()
    digitalWrite( Dir   , sens);
    digitalWrite( Step  , LOW);
    // Fabrication d'un "Pas"
    digitalWrite( Step, HIGH );
    digitalWrite( Step, LOW );

Just a google search and I got on [this site][2] which had the code I gave you. I think you can also find some libraries that can do the work for you.

in case that you need to wait less than a millisecond, millis() won't be useful for you; instead, use delayMicroseconds() which will make you wait a thousandth (at minimum) of a millisecond.


For what you asked you have to first get the voltage:

float voltage = analogRead ( 0 )  * (3.0 / 1023.0);

You just have to adapt your speed relatively to the voltage. To do this, I suggest you the map function directly from Arduino site.

Be careful just because whatever you are doing, analogRead takes 100 microseconds to get the voltage, so if you need to go very fast you can't. I suggest you to work with a different type of communication, like Serial, SPI or I2c.

  • Thanks, Can you tell me how can i control motor speed/RPM using a analog voltage which came from some other device. The voltage are range in 0-3V.
    Mar 4, 2015 at 2:27
  • There you go. I edited the answer for your question
    – Stefa168
    Mar 4, 2015 at 7:58

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.