I am trying to run a stepper motor using an Arduino stepper motor shield like the Adafruit V1 motor shield. In my code I am just trying to get the motor to rotate forwards and backwards. When I first try uploading and running the code I can get a forward and reverse rotation, but then the motor begins jittering inconsistently. I have tried changing my wiring setup but generally get the same results. Here is the data sheet for the motor I am using. I have the board it connected to a 12v battery. I also got the same problem when trying to drive the motor using just an H-drive chip. I have included my code below as well as a picture of my wiring. Here is a video of the jitter.

#include <AFMotor.h>
AF_Stepper motor(200, 1);
void setup() {
Serial.begin(9600);           // set up Serial library at 9600 bps
Serial.println("Stepper test!");

motor.setSpeed(120);  // 10 rpm   

motor.step(100, FORWARD, SINGLE); 

void loop() {
motor.step(200, FORWARD, DOUBLE);

motor.step(200, BACKWARD, DOUBLE);

enter image description here

  • please run the example code that is included with the library – jsotola Feb 26 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.