Arduino Uno Adafruit MotorShield v2 Stepper Motor Code for Continuous Rotation

I have an arduino uno, an adafruit motor shield v2, and stepper motor and power supply!

I desperately need a code For my senior project for mechanical engineering!
I have a power supply and plan to turn that on when I need it to run and turn it off when I need it to stop!

All I need is a code That will rotate the motor in one direction. I dont ever need it to stop because I will just shut off the power when I want to stop it!

This is my current code and it does allow the motor to work!!

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include “utility/Adafruit_MS_PWMServoDriver.h”

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Stepper test!”);

AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz

myMotor->setSpeed(100); // 10 rpm
}

void loop() {

Serial.println(“Double coil steps”);
myMotor->step(100, FORWARD, DOUBLE);

}

So what is your code doing now? And what are you expecting it to do?

The code just moves it back and forth, which is what I expected it to do. Its from an example on Arduino. I have been having trouble with every code I had got online loading onto my arduino. There is always errors. So I wanted to show this code so that anyone helping me with a code will know that this at least makes the motor move and arduino work

I only need it to rotate one direction. I want to be able to edit the rpm. But I dont want anything else!

I'm not familiar with stepper motor but what happens if you just step it by smaller amount and add a delay(500); after the step?

It will rotate a small amount, but while doing so it kind of vibrates back and forth

The code just moves it back and forth, which is what I expected it to do.

Why do you expect code that tells the motor to move in one direction, over and over, will make the motor move back and forth?

I suspect that your stepper motor is not connected to your motor driver correctly, or that you aren't using a proper stepper driver.

Post a link to the stepper motor driver you are using.