Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save monpetit/0cbc515fbbf4b3094ce040de37105871 to your computer and use it in GitHub Desktop.

Select an option

Save monpetit/0cbc515fbbf4b3094ce040de37105871 to your computer and use it in GitHub Desktop.
#include <Stepper.h>
const int steps = 600;
// initialize the stepper library on pins 8 through 11:
Stepper motor(steps, 8, 9, 10, 11);
void setup()
{
// set the speed at 60 rpm:
motor.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop()
{
// steps in one direction:
Serial.println("clockwise");
motor.step(steps);
delay(500);
// steps in the other direction:
Serial.println("counterclockwise");
motor.step(-steps);
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment