Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Major A4988 problem


hello , i am using the A4988 stepper motor driver , and there is a problem .
the datasheet specifies that a step is done by the motor on a low to high shift on the step pin .
to test my S motor driver . i am using this simple arduino code :

void setup(void){

  digitalWrite(2,1); //dir
  digitalWrite(6,0); //en

uint16_t X=100;

void loop(void){
  for(uint16_t x=0;x<200;x++) {
                    digitalWrite(3,1); delayMicroseconds(500); digitalWrite(3,0); delayMicroseconds(500);


now the stepper motor has 1.8deg step , so 200 steps must do a full revolution . so the motor has to do a full turn , wait for a second then do an other and so on . according to the datasheet the value of X should not change anything . when X is 0 , everything works . the motor does a 360deg turn every 1s . now the problem is when i use a real value for X . like 1 , 2 , 10 , 50 or 100 . the motor does less than 360degrees . which means that it does not do a full revolution before stopping for 1s . it does less than 360deg stops for 1s then does less than 360deg and so on …
i have been struggling with this for a couple of days now and i can’t understand it .


if any additional information is needed i am willing to provide it .
is the problem that complicated ? (due to the fact that no one responded)

thank you



Your code is difficult to follow because you are using variable names that differ only in case and your spacing does not follow standard conventions, however it looks like you probably have connected pin 3 of your Arduino to the step pin of your A4988. It is possible that your code it sending the right signals, but that the stepper hardware is not set up correctly. Can you post pictures here that show how everything is connected? Did you set the current limit on your stepper driver and, if so, what did you set it to? What kind of power supply are you using? Do you have a datasheet or any other information about your stepper motor you could post here?



thank you very much for your response sir .

yes pin3 is the step pin .

motor : 17hs2408
datasheet : www.datasheetspdf.com/datasheet/17HS2408.html
power supply : 12V DC 2A
i am 100% sure that the wiring is correct .

i did not set the current limit on the stepper driver though . could that cause a similar problem ? and if it can how can i set the current limit ? (i know it’s done by turning the pot , but how much do i need ?)

thank you .


this is the exact motor :


Having an inproper current limit setting could cause a lot of strange behaviors. The video in this blog post shows how to set the current on our A4988 driver boards.



thank you very much sir .
i fixed the current limit and everything worked like magic .

thank you very much i highly appreciate it .