#include <Stepper.h>
int STEPS = 200; // change this to the number of steps on your motor
Stepper stepper(STEPS, 4, 5, 6, 7); //create a stepper class and set pins
void setup()
{
stepper.setSpeed(30); // set the speed of the motor to 30 RPMs
}
void loop()
{
stepper.step(200); //step forward 200 steps (1 revolution)
delay(200);
stepper.step(-400); //step backward 400 steps (2 revolutions backwards)
delay(200);
}
Note: The standby pin turns the whole chip on and off. In the diagram above it is constantly set high to 5V but you may manually turn on and off the chip by sending either a high or low signal from an Arduino pin to control the chip. This is beneficial so that you are not constantly pulling power from your source, and heating up your stepper.